We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33101
    • 46 Posts
    i have a general snippet that will pull misc data from the database and display. Is it possible to modify the [*pagetitle*] or any other page content or template variables via a snippet? Does it matter if the snippet is called before or after the TV-to-be-changed in the template?

    Thank you,
    Yehosef
      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: yehosef at Nov 28, 2006, 08:01 AM

      i have a general snippet that will pull misc data from the database and display. Is it possible to modify the [*pagetitle*] or any other page content or template variables via a snippet? Does it matter if the snippet is called before or after the TV-to-be-changed in the template?

      Thank you,
      Yehosef

      You could specify a TV tag or placeholder tag in the pagetitle value. Then have an @EVAL in the TV, a plugin on an appropriate event, or a snippet on the page set the value of the placeholder. As long as it’s not nested within too many other tags, it shouldn’t matter what order they are called.
        • 33101
        • 46 Posts
        Quote from: OpenGeek at Nov 28, 2006, 08:58 AM


        You could specify a TV tag or placeholder tag in the pagetitle value. Then have an @EVAL in the TV, a plugin on an appropriate event, or a snippet on the page set the value of the placeholder. As long as it’s not nested within too many other tags, it shouldn’t matter what order they are called.


        Thanks for the reply - two questions:

        1) Can I understand from your answer that you cannot modify these variables via a snippet - even using the MODx API or the document parser class?

        2) You mentioned a placeholder - how would I use a placeholder in a template? - placeholders are [+something+] - right? If I put a [+title+] in my template, how would I set that value?

        TIA,

        Yehosef
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: yehosef at Nov 29, 2006, 02:05 AM

          1) Can I understand from your answer that you cannot modify these variables via a snippet - even using the MODx API or the document parser class?
          The real question is, do you want to just change the value occasionally so that it is reflected to the next person (i.e. actually change the value in the database), or is it just a personalization of the value for every request? You can change the pagetitle in the db, but that isn’t very efficient to do when requesting and processing the page. It’s much more efficient to put a dynamic placeholder there and set it on each request in a snippet (or plugin).

          Quote from: yehosef at Nov 29, 2006, 02:05 AM

          2) You mentioned a placeholder - how would I use a placeholder in a template? - placeholders are [+something+] - right? If I put a [+title+] in my template, how would I set that value?
          $modx->setPlaceholder('title', $newTitleValue);