Jump to:

3435 Posts in 1026 Topics by 866 members

Template Questions

SilverStripe Forums » Template Questions » access page.php function inside menu loop

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1369 Views
  • pbenoit
    Avatar
    Community Member
    9 Posts

    access page.php function inside menu loop Link to this post

    Hi all,

    I have a menu loop and im struggling to get a function I need to run within it.

    I have the functions on my page.php file so it should be accessed by all pages. Calling the function is ok in the nav include outside the menu loop but not inside.

    Basiclly im trying to show a share price value from an XML file inside a dropdown nav. Any ideas??

    <ul class="nav_pri">
       <% loop Menu(1) %>
          <li class="$LinkingMode">
             code
             <% if Children %>
                code
                   <% if $MenuTitle="Investors" %>
                      access function from page.php $sahre_price
                   <% else %>
                      show something else
                   <% end_if %>
                code
             <% end_if %>
          code
       <% end_loop %>
    </ul>

  • Willr
    Avatar
    Forum Moderator
    5490 Posts

    Re: access page.php function inside menu loop Link to this post

    I have the functions on my page.php file so it should be accessed by all pages. Calling the function is ok in the nav include outside the menu loop but not inside.

    Make sure the function is inside the Page class part of the file. SilverStripe won't pick up anything outside of the page class in this context, and if it's in the controller class in that file you'll only see it on the top level.

  • pbenoit
    Avatar
    Community Member
    9 Posts

    Re: access page.php function inside menu loop Link to this post

    Thanks Willr,

    Adding this seems to have caused an issue with the site, instead of looking for 'pageType_live' in query strings it's now using 'pageType' only.

    This caused some large issues with our server and crashed everything.

    Any ideas?

    Phil

  • Willr
    Avatar
    Forum Moderator
    5490 Posts

    Re: access page.php function inside menu loop Link to this post

    This sounds like more an issue with what your code does rather than where. Post it here and people may be able to suggest fixes.

    1369 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.