We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29181
    • 480 Posts
    Hi,
    Has anybody ever had to CSS a wayfinder output by row in the past? My initial plan was to use &rowIdPrefix but that uses the Id of the doc as opposed to an increment starting at 1 or something like that. My next plan will be to look into the source of Wayfinder (EEK!!) and see if I can set an incrementing variable which counts to 4 then resets itself to 1 (I need 4 different backgrounds).

    My other problem is that some of the links require a special image in front of the actual link. Is there any way of acheiving this? I could set a image TV for each page with the src of the little icon. Then I could (possibly) grab that TV value and insert it into the template for the row template somehow?

    Do either of these sound feasible, has anybody already acheived this type of functionality (and is willing to share wink) or would recommend a totally different approach.

    Thank you for your valued suggestions!

    All the best,
    Taff
      Adrian Lawley: www.adrianlawley.com
      • 11975
      • 2,542 Posts
      Hi,

      you can easily access TV with WF 2.0

      in your rowTpl = add a placeholder [+mytvIDcss+]

      and then set the background image in your css file.

      :-)
        Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
        • 29181
        • 480 Posts
        Heliotrope,
        thanks very much for the reply. That will work perfectly for the image in front of the link problem! I’ll set the default value to a spacer.gif and adjust the 5 or 6 that require an image accordingly. Thanks again!

        I still haven’t had much success with the other problem of getting the links to have a yellow, blue, red or green background in that order as they are generated. I looked at the config settings and thought maybe I could add a little function or a $i++ to the rowTpl but unfortunately that doesn’t work. I had a quick delve into the wayfinder.inc.php too....but got lost very soon.

        Thanks,
        Taff
          Adrian Lawley: www.adrianlawley.com
          • 29181
          • 480 Posts
          After diggin’ a little deeper with my very limited PHP knowledge...this is my solution:

          I added a

          'countFrom' =>isset($countFrom) ? $countFrom :FALSE,


          to the config array in the Wayfinder snippet.

          In the wayfinder.inc.php file I:

          changed the ’rowLevel’ array to look like this:

          'rowLevel' => array('[+wf.wrapper+]','[+wf.classes+]','[+wf.classnames+]','[+wf.link+]','[+wf.title+]','[+wf.linktext+]','[+wf.id+]','[+wf.counter+]','[+wf.attributes+]','[+wf.docid+]','[+wf.introtext+]','[+wf.description+]','[+wf.subitemcount+]')


          hence adding a [+wf.counter+] placeholder into the row template

          I created a cunningly named countUp function:

          function countUp(){
          	global $modx;
          	$this->counter++;
          	return $this->counter;
          	}


          In the renderRow function I added another if clause straight after the rowIdPrefix, nigh on duplicating it to use the countUp data which looks like:

          if ($this->_config['countFrom']) {
                      $getCounter = $this->countUp();
          			while ($getCounter > $this->_config['countFrom']){
          			$getCounter = $getCounter - $this->_config['countFrom'];
          			}
          			$countUp=$getCounter;
                  } else {
                      $countUp = '';
                  }


          I just need to amend the $phArray now to integrate my wf.counter placeholder at the right place, if you remember rightly we amended the rowLevel array at the top in a similar way, so now we add a $countUp array between the $useId and $resource[’link_attributes’] so now it looks like

          $phArray = array($useSub,$useClass,$classNames,$resource['link'],$resource['title'],$resource['linktext'],$useId,$countUp,$resource['link_attributes'],$resource['id'],$resource['introtext'],$resource['description'],$numChildren);
           


          In the wayfinder call I can now add a parameter &countFrom=`n` where n is where you want it to restart counting.

          In my case I have 4 bg images and therefore &countFrom=`4` which I add to my config file to get it to load bg_image1 thru to bg_image4 hopefully ;-)

          As already mentioned I have little PHP knowledge so don’t know about overheads and other pitfalls. One possible problem is if you have &level as anything but 1....I think it will count nested...but for my client I don’t need sub menus so I’ll cross that bridge when I come to it.

          Cheers Helio for your help,
          Taff


            Adrian Lawley: www.adrianlawley.com