On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Hello,

    I use Evo 1.0.5.

    I have a ressource generated with YAMS http://modx.com/extras/package/yams
    in 3 langunges. Each language has a seperate menutitle.

    I call the wayfinder like this (works fine):
     [[Wayfinder? &startId=`0` &outerClass=`nav` &rowTpl=`@FILE:assets/modules/yams/tpl/wayfinder/docr/row.tpl` &innerRowTpl=`@FILE:assets/modules/yams/tpl/wayfinder/docr/innerrow.tpl` ]]

    In my rowTpl I use images (rotated) for the menutitle instead of plain text. I call my snippet in the rowTpl like this:
     <a href="(yams_docr:[+wf.docid+])" title="[[YAMS? &get=`data` &docid=`[+wf.docid+]` &from=`pagetitle`]]" [+wf.attributes+]> <img src="[[Generate_main_menu_img? &id=`[+wf.docid+]` &text=`((yams_data:[+wf.docid+]:menutitle_(yams_id)))` &lang=`(yams_id)` ]]" alt="" /> ((yams_data:[+wf.docid+]:menutitle_(yams_id))) </a>

    The snippets Generate_main_menu_img gets called in the src attribute of the Image.
    The snippet returns the src of the generated image for the navigation.

    The pages are cached, the wayfinder is cached and the snippet is cached because I dont want to generate the images new for each page-call. When I remove the cache like [! ... !] for the snipped it works fine. But when I cache it as in this version, nothing happens even if I delete the cache.

    The snipped. which generates my images looks like this:
    $img_width = 23;
    $img_height = 260;
    $font_size = 23;
    $angle = 90;
    $font = "assets/fonts/svett.ttf";
    $path = 'assets/templates/standard/img/nav/'.$lang.'/'.$id.'.gif';
    $dimensions = imagettfbbox ( $font_size , $angle , $font , mb_strtoupper($text, 'UTF-8') );
    //grey inactive
    $im = imagecreate($img_width, $img_height);
    $white = ImageColorAllocate ($im, 240, 237, 235);
    $black = ImageColorAllocate ($im, 198, 199, 200);
    ImageTTFText ($im, $font_size, $angle, 23, -$dimensions[5], $black, $font, mb_strtoupper($text, 'UTF-8'));
    imagegif($im, $path);
    //red active
    $black = ImageColorAllocate ($im, 226, 0, 26);
    ImageTTFText ($im, $font_size, $angle, 23, -$dimensions[5], $black, $font, mb_strtoupper($text, 'UTF-8'));
    imagegif($im, 'assets/templates/standard/img/nav/'.$lang.'/'.$id.'a.gif');
    return $path;


    • Is there a way to get those generated images for the navigation cached?

      When I use the snipped cached with [! .... !] it outputs static content like
      • hi,

        not sure about the caching stuff but what about using
        if ( !file_exists('assets/templates/standard/img/nav/'.$lang.'/'.$id.'.gif') {}

        around you snippet ?
        it wouldn't be perf consuming and would help you not regenerating your img on each page call

        the only thing is you may have to write a plugin that empties the nav img folder onBeforeCacheUpdate or onCacheUpdate in order to be able o change the page titles without having to empty it a la mano
        something really easy to do actually

        have swing
          réfléchir avant d'agir