That's fine Tiffany. Just wanted to 1) Clarify that best practices for this software include never having to change the core so upgrades are always easy.
2) Make sure you knew I was committed to creating whatever hooks you needed to make that possible. And yes, there is no need to worry about infinite loops with toolmapping. Cheers, Dan On Sat, Oct 4, 2014 at 8:10 AM, Tiffany Grenier <[email protected]> wrote: > Well, we have different ways of thinking, and I don't think one of us will > change their point of view :-) > I don't want to make you change how Boltwire works, so let's stop there. > Moreover, the next additions I have in mind are real plugins (a bunch of > related new features that do more than simply improving a bit the core > ones) and I will publish them as such. > About you suggestion of writing the following, > function myBOLTFbreadcrumb($args, $zone='') { > if (some condition) return BOLTFbreadcrumb($args, $zone=''); > // my stuff... > return $myOutput; > } > I just feared that this would create infinite loops,since BOLTFbreadcrumb > would tend to be immediately replaced by myBOLTFbreadcrumb... but it's > apparently only when called from the content of a webpage :-D > > > Cheers,Tiffany > > Le vendredi 3 octobre 2014 13:38:30 UTC+2, Dan a écrit : >> >> I'm not sure we are understanding each other. >> >> If you use the toolmap approach (or webhooks) like I suggested, you can >> automatically dump any new upgrade over your system and none of your new >> functionality should be lost. That's the whole point of the design. No need >> for variant core code. No diff or merge required--and you always keep your >> changes. >> >> Neither plugins, config.php, or farm.php are overwritten by the core. Any >> thing in those files will continue to work exactly as before whenever >> BoltWire gets upgraded. >> >> The other advantage of designing it as a normal proper plugin, is it >> makes it easy to share with other users. :) They just drop it into their >> plugins folder and either enable it sitewide or for specific sections of >> their site and it instantly works. And they can upgrade freely too without >> having to worry about losing their plugin features. And they don't have to >> worry about maintaining variant code on their system. >> >> As for your example, you CAN do it exactly as you posted. Or you can use >> either of the following ways as well--which would be even simpler: >> >> 1) Put your conditions in the custom plugin: >> >> function myBOLTFbreadcrumb($args, $zone='') { >> if (some condition) return BOLTFbreadcrumb($args, $zone=''); >> // my stuff... >> return $myOutput; >> } >> >> or >> >> 2) Only turn on the toolmap in certain situations: >> >> if (some condition) $BOLTtoolmap['f']['breadcrumb'] = >> 'myBOLTFbreadcrumb'; >> >> The first is preferable to your example because there's no need to >> BOLTFbreadcrumb if you are not going to use it. The second saves a step or >> two more--only turning on the alternate version of the function when you >> need it. >> >> You are welcome to use any approach you like--but I think you'll find the >> normal plugin approach easier in the long run. >> >> If I'm not understanding something, let me know. :) >> >> Cheers, >> Dan >> >> >> On Fri, Oct 3, 2014 at 5:57 AM, Tiffany Grenier <[email protected]> >> wrote: >> >>> Hi Dan, >>> >>> I understand what you would like me to do, but I have to warn you that >>> most of the time, I will not do it your way... Because there are times when >>> I do NOT want to see some new feature disabled because I did not update all >>> my plugins according to your changes. >>> >>> If the code allowed me to do the following, I would not hesitate one >>> second: >>> function myBOLTFbreadcrumb($args, $zone='') { >>> $normalResult = BOLTFbreadcrumb($args, $zone=''); >>> if( some case where I do not want to get limited by default >>> behaviour) { >>> $myResult = ... >>> return $myResult; >>> } >>> return $normalResult; >>> } >>> >>> For such new features that just add some small behavior to the core one, >>> I do not want to have a function that I will need to update each time the >>> core changes. Therefore, I modify the core and process a diff/merge at each >>> new release to keep my small addition AND your new code without the need to >>> change my code. >>> >>> Cheers, >>> Tiffany >>> >>> >>> Le jeudi 2 octobre 2014 18:58:04 UTC+2, Dan a écrit : >>>> >>>> Wow some great suggestions... >>>> >>>> BREADCRUMB >>>> Here's how you could have done the modified breadcrumb function as a >>>> plugin. You would either put this in config.php or a custom plugin that you >>>> enable for your site. >>>> >>>> $BOLTtoolmap['f']['breadcrumb'] = 'myBOLTFbreadcrumb'; >>>> >>>> function myBOLTFbreadcrumb($args, $zone='') { >>>> // your modified version of the system function >>>> } >>>> >>>> Basically when BoltWire is called to generate a breadcrumb, it sees the >>>> toolmapping value and calls your function rather than mine. The advantage >>>> to this approach, is you never have to worry about your changes to the core >>>> code being overwritten during an upgrade. My goal is always to enable you >>>> to do anything without ever having to hack the core. >>>> >>>> SEARCHPAGELIST >>>> Unfortunately, the BOLTsearchPageList function does not have a webhook. >>>> So to let you customize this function, I would normally add one, by >>>> inserting this line at the very top of the system function: >>>> >>>> function BOLTsearchPageList($args, $zone='', $auth=true) { >>>> if (function_exists('myBOLTsearchPageList')) return >>>> myBOLTsearchPageList($args, $zone='', $auth=true); >>>> ... >>>> >>>> You could then copy the system function to your config.php file or >>>> plugin, renamed it myBOLTsearchPageList, and your function would be used >>>> instead of mine. The goal again is to make it possible to do anything >>>> without hacking the core. >>>> >>>> In this case however, I like both your suggestions and will add them to >>>> the next release. The second one is particularly elegant. Will update the >>>> docs. >>>> >>>> Cheers, >>>> Dan >>>> >>>> >>>> >>>> >>>> On Thu, Oct 2, 2014 at 1:39 AM, Tiffany Grenier <[email protected]> >>>> wrote: >>>> >>>>> Hi, >>>>> >>>>> I don't know if this might be of interest for someone, or even be >>>>> integrated into the core at some point, but I created a hooks >>>>> for BOLTFbreadcrumb and BOLTsearchPageList, allowing you the following >>>>> things: >>>>> >>>>> - add an argument limit to breadcrumb, in order to display only N >>>>> items (+ the final one if there are more than N page levels) >>>>> - add argument final (by default "...") to breadcrumb that tells >>>>> what should be placed between seperators instead of the "hidden" >>>>> levels, >>>>> thus between item N and N+1 if there is a N+1 (as you can see in >>>>> attached >>>>> picture, where limit is 3) >>>>> - add the possibility to search for group=page.+ (or group=page+, >>>>> or group=page.+.+.+) in addition to group=page.*, in order to be able >>>>> to >>>>> limit the number of levels we want to search for, without having to use >>>>> patterns >>>>> >>>>> >>>>> How to do it? For each method, just copy-paste current code into a >>>>> hook and apply following patches to the hook methods: >>>>> >>>>> - BOLTFbreadcrumb (file functions.php) >>>>> - between lines 29 and 30, add: >>>>> - $lastseparator = $separator.BOLTinit('...', >>>>> $args['final']).$separator; >>>>> - between old lines 48 and 49 - therefore between new lines 49 >>>>> and 50 -, add: >>>>> - $outlast = ''; >>>>> if ((isset($args['limit'])) && ((isset($args['offset'])) >>>>> && (($args['limit']+$args['offset']) <= $last) || >>>>> ($args['limit'] <= $last))) { >>>>> if (isset($out[$last])){ >>>>> if((isset($args['offset'])) && (($args['limit']+$args[' >>>>> offset']) == $last) || ($args['limit'] == $last)) >>>>> $lastseparator=$separator; >>>>> $outlast = $out[$last]; >>>>> unset($out[$last]); >>>>> } >>>>> } >>>>> - between old lines 49 and 50 - therefore between new lines 58 >>>>> and 59 - , add: >>>>> - if (isset($args['limit'])) $out = array_slice($out, 0, >>>>> $args['limit']); >>>>> - before the return, add: >>>>> - if($outlast != '') $out = $out.$lastseparator.$outlast; >>>>> - BOLTsearchPageList (file library.php) >>>>> - replace line 1634 by: >>>>> - if (strpos($p, "*") !== false || strpos($p, "+") !== >>>>> false) { >>>>> - between lines 1638 and 1639, add: >>>>> - $p = str_replace('+', "[$namespat]*", $p); >>>>> >>>>> >>>>> That's it! >>>>> That's not really a recipe, nor a plugin, so I didn't know where to >>>>> put it in the website documentation... >>>>> >>>>> Regards, >>>>> Tiffany >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "BoltWire" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to [email protected]. >>>>> To post to this group, send email to [email protected]. >>>>> Visit this group at http://groups.google.com/group/boltwire. >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> >>>> -- >>> You received this message because you are subscribed to the Google >>> Groups "BoltWire" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To post to this group, send email to [email protected]. >>> Visit this group at http://groups.google.com/group/boltwire. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- > You received this message because you are subscribed to the Google Groups > "BoltWire" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/boltwire. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "BoltWire" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/boltwire. For more options, visit https://groups.google.com/d/optout.
