We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2940
    • 17 Posts
    Hi,

    I found on the forums http://modxcms.com/forums/index.php/topic,3847.0.html an old post about it (from 2006), but the only answer was that using
    $modx->documentObject['pagetitle'] = "HELLO WORLD";

    should let me change it.

    I’m in almost the same situation as the cited user, need to change pagetitle and/or menutitle for dinamically displayed products.

    So the question is: at what point I can change these parameters to be visible on the page? Can I put a snippet in a template, before the <html> tag to set these values? Or there is other way?

    Any hint will be appreciated!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      To do so early enough to make a difference, you’ll need to use a plugin.

      http://www.sottwell.com/how-plugins-work.html
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 2940
        • 17 Posts
        First, thank you for the tip Susan. (I’ve been away for a looong while)

        by the way I found that in the pagetitle and menutitle input field I can put a snippet and it worked! Assume that this is not an appriopiate solution.

        Another question on my mind:

        If I want to have dynamic aliases could it be done via plugin as well? (retrieve desired name from DB, and set it $modx->documentObject["alias"]=’my_alias’)

        Regards,

        B
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          That would be a bit problematic, I would think; while it could be done how would that affect search engines and people’s bookmarked links? Search engines don’t like it when the same page is reached via different URLs.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 2940
            • 17 Posts
            I see that didn’t made myself clear.

            Instead of:
            www.mysite.com/index.php?id=12&category_id=45&product_id=57
            


            would like to have:

            www.mysite.com/page/category_name/product_name.html
            


            I’ve already got fURL’s going. so the fURL now is:

            www.mysite.com/page/category_generic/product_generic.html?category_id=45&product_id=57
            


            The structure is:

            [tt]
            + page (id=10)
            + category_generic (id=11)
            - product_generic (id=12)

            [/tt]

            If the "search engines don’t like it when the same page is reached via different URLs" what for the fURL’s are?? smiley

            Arent’t we reaching the same page [tt]index.php?id=XX[/tt] with different URL’s ?


              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Ok, I didn’t understand exactly what you were doing.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 2940
                • 17 Posts
                no problem, my fault

                but I really hit the wall with this one. Your help will be more than appreciated.
                  • 22303 MODX Staff
                  • 10,725 Posts
                  You can do this with custom .htaccess and a Snippet to generate your proper URLs, OR (this is my preferred method) you can use OnPageNotFound event with a Plugin to parse the REQUEST_URI, set the GET parameters you need to manually, and forward the request to your page using $modx->sendForward($resourceId). MODx is already virtually handling requests for anything that is not a file or folder, so why not take over where the default routing ends to customize it for a particular Resource view you are developing. Please see this post for an example.
                    • 2940
                    • 17 Posts
                    Thanks, sounds really complicated, I’m on the snippet ’level of evolution’ smiley at the moment, plugins sounds scaaaary.

                    See what I can do.