We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37393
    • 68 Posts
    Hey there, i would like to add and modify default values in default placeholders such as [[*pagetitle]] dynamically, however, i am using BreadCrumbs as well and would like to add the current (dynamic) pagetitle to the end of the crumb where the parents pagetitle is listed.


    I have a snippet creating dynamic $_get vars to get hold of a page that are in the parents folder


    http://www.domain.com/user-galleries/?action=add-album


    Breadcrumb is now: Home | User Galleries <- Because the dynamic page that is called with the $_get var is called within the parents page and therefore the parents pagetitle will only be displayed.

    BUT

    I want it to be like this: Home | User Galleries | Add Album


    How can i do this in the professional way?
      IntoVPS - VPS hosting service with super-fast response.
      If MODx does not suit your needs then you have a lack of imagination.
      • 37163
      • 6 Posts
      You could try creating a new snippet for the purposes of extending the 'Breadcrumbs' class. You could try capturing the output of Breadcrumbs->run(), and then modify it to append a custom crumb. If you just want to add 'Add Album' (or any other piece of text) as an additional crumb for the current resource then you could try something like this:

      e.g: 'MyBreadcrumbs' snippet:

      <?php
      require_once $modx->getOption('breadcrumbs.core_path',null,$modx->getOption('core_path').'components/breadcrumbs/').'model/breadcrumbs/breadcrumbs.class.php';
      
      class ExtendedBreadCrumbs extends BreadCrumbs {
      	public function run() {
      		$output = parent::run();
      		if(!empty($this->config['extra_crumb'])) {
      			$output = str_replace('B_lastCrumb','B_Crumb',$output);
      			$extra = ' '.$this->config['crumbSeparator'].' ';
      			$extra.= $this->getChunk('bcTplCrumbLast',array(
                  	'text' => $this->config['extra_crumb'],
                  ))."\n";
      			$output = str_replace('</ul>',$extra.'</ul>',$output);
      		}
      		return $output;
          }
      }
      
      $bc = new ExtendedBreadCrumbs($modx,$scriptProperties);
      return $bc->run();


      You could pass the text / string in your snippet call along with all other standard 'Breadcrumbs' script properties.

      e.g.

      [[!MyBreadcrumbs? &currentAsLink=`1` &extra_crumb=`Add Album`]]


      Would produce something like

      Home > Current Page > Add Album

      ? [ed. note: spiltmilk last edited this post 14 years, 4 months ago.]