We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27305
    • 173 Posts
    I have a side navigation on all my pages, that I’m using wayfinder to generate, works fine. I have one section called awards, that I would like to have sorted and catogorised by year so something like

    2007
    ----------------
    Award one
    Award two

    2006
    ----------------
    Award one
    Award two

    I was just wondering should I do this using reflect? or wayfinder.

    I had a quick stab at trying to get reflect working, but can’t find much information about the parameters. I would like to change the templates, but don’t want to hack the snippett, not sure how to have my own chunks to replace the below code in the snippet, any help would be great.


    // ---------------------------------------------------
    //  Default Templates
    // ---------------------------------------------------
    
    $defaultTemplates['tpl'] = <<<TPL
    <h3>Archives</h3>
    <div class="reflect_archive_list">
    	[+archive_items+]
    </div>
    TPL;
    
    $defaultTemplates['year'] = <<<TPL
    <a href="[+url+]" title="[+year+]" class="reflect_year_link">[+year+]</a>
    TPL;
    
    $defaultTemplates['month'] = <<<TPL
    <a href="[+url+]" title="[+month+] [+year+]" class="reflect_month_link">[+month+]</a>
    TPL;
    
    $defaultTemplates['item'] = <<<TPL
    <a href="[~[+id+]~]" title="[+pagetitle+]" class="reflect_item_link">[+pagetitle+]</a> (<span class="reflect_date">[+date+]</span>)
    TPL;
      I made my first site with modx
      ------------------------
      Shopping blog
      Sky+ HD
      • 2581
      • 10 Posts
      I have had very similar issues and haven’t managed to overide the default reflect snippet huh

      Historically I have been using wordpress style archives do to migrating from Wordpress, unfortunately Modx isn’t as easy as wordpress when ti comes to generating archive links, here is a quick summary of what I have found / what I have done / where I am stuck.


      • I have stopped using config=`wordpress` in my reflect call (this is actually calling a configuration php file in the reflect folder which is a template override)
      • I am using reflect to pump out to a page using a template called News Archive - By Year (this works)
      • I have been trying to call replacement tpl holders (instead of using a config file... I am now tempted to try and write one)

      End results


      • I cannot seem to overide the default wrapper template even if I comment out the default tplContainer in the reflect snippet.
      • the depth parameter doesn’t function how I would expect it... I always seem to get year -> month loop -> post loop when all I want is year

      The good part

      If I could just get rid of the 2nd level links for month and item then I would have the solution but up until now I am completely lost.

      I am at work so will post my actual code when I get home.

      I cannot actually believe how awkward this is to do, I guess this is down to understanding the concept and then it will be easier but this used to be straight forward for me and I have spent waaaaay too much time trying to figure it out through trial and error.

      Hope someone can help smiley




        Loving modx but hating too... is that a love hate thing or what?
        • 2581
        • 10 Posts
        A little more info:

        I have been using the following to try and bypass the defaults.

        &tplContainer=`wrapperYear` &tplYear=`tplYear` &tplMonth=`tplMonthEmpty` &tplItem=`tplItemEmpty`


        I have the the yearWrapper chunk working which contains
        <ul>
        [+wrapper+]
        </ul>


        and the tplYear chunk contains something along the lines of:

        <li><a href="">year name</a></li>


        I am wondering if I need to call &tpl=`tplYear` instead to get the list items to loop...  going to try this when I get home.

        I don’t know if I just had a moment of clarity or not but I am basing it off of the following in the defaults (in bold):

        $defaultTemplates['[b]tpl[/b]'] = <<<TPL
        <h3>Archives</h3>
        <div class="reflect_archive_list">
        	[+archive_items+]
        </div>
        TPL;


        As an aside:

        I have tried injecting @CODE into my tplYear to no avail sad


          Loving modx but hating too... is that a love hate thing or what?
          • 2581
          • 10 Posts
          Update:

          * I have now created a config file and uploaded it to /assets/snippets/reflect/configs/ and the file is called yearArchive.config.php
          <?
          // Use the following syntax $param = 'value';
          $showItems=0;
          $groupByYears=1;
          $tplYear = '@CODE <a href="[+url+]" title="[+year+]">[+year+]</a>';
          ?>
          


          I use the following chunks:

          {{yearArchives}}

          [!Reflect?config=`yearArchive` &targetID=`450` &getDocuments=`1` &extenders=`dateFilter` &sortBy=`pub_date` &dateSource=`pub_date` &dittoSnippetParameters=`parents:75` &id=`wp` &tplContainer=`sidebarArchives` &phx=`1` !]


          {{sidebarArchives}}

          <div id="side-archive">
          <h2>Archives</h2>
              [+archive_items+]
          </div>
          


          This gives me the archive format of :

          2008
          January
          Febuary
          2007
          etc
          etc

          Does anyone out there know how to remove the months as this is driving me nuts!!!

          Any help appreciated.

          Oh.. and in case it helps... the code generated is as follows:

          <ul class="reflect_archive">
          <li class="reflect_year"><a href="/mformation-news/date-archive-by-year?wp_year=2008&wp_month=false&wp_day=false&wp_start=0" title="2008">2008</a>
          <ul>
          <li class="reflect_month"><a href="/mformation-news/date-archive-by-year?wp_month=2&wp_year=2008&wp_day=false&wp_start=0" title="February 2008" class="reflect_month_link">February</a> </li>
          </ul>
          </li>
          <li class="reflect_year"><a href="/mformation-news/date-archive-by-year?wp_year=2007&wp_month=false&wp_day=false&wp_start=0" title="2007">2007</a></li>
          </ul>


          TIA



            Loving modx but hating too... is that a love hate thing or what?
            • 19537
            • 2 Posts
            Hi everyone who could quickly help me:

            This is my problem:
            http://www.foref.info/site-map

            scroll down to "Archives"
            When i click on a Link, for example "2010" it just reloads the current page, what shall i do, test it yourself!

            Thanks alot to you!!!