We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49546
    • 1 Posts
    I'm using PHP to get the [[*pagetitle]] and the if the title is "Home" I only want to return a title that is the [[++site_name]]. For all other pages, I want to return [[*pagetitle]] | [[++site_name]]. Attached is what I have, but it only outputs the [[*pagetitle]] | [[++site_name]] to all pages.

    This question has been answered by multiple community members. See the first response.

    • discuss.answer
      • 4172
      • 5,888 Posts
      you can use a output-filter:
      [[*pagetitle:is=`Home`:then=`[[++site_name]]`:else=`[[*pagetitle]] | [[++site_name]]`]] 
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
      • discuss.answer
        • 4172
        • 5,888 Posts
        if you snippet would look like that:

        <?php
        
        if ($currentPage == "Home") {
            return "[[++site_name]]";
        }
        else {
            return "[[*pagetitle]] | [[++site_name]]";
        }


        this should work:

        [[yoursnippet? &currentPage=`[[*pagetitle]]`]]


        or get the pagetitle inside your snippet with:

        <?php
        
        $currentPage = $modx->resource->get('pagetitle');
        
        if ($currentPage == "Home") {
            return "[[++site_name]]";
        }
        else {
            return "[[*pagetitle]] | [[++site_name]]";
        }


          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!