We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32756
    • 25 Posts
    I am absolutely stuck with trying to figure out a glitch I have with template variables.

    I tried going to the official documentation, but the doc page for template variables is broken...the text loads, but all of the images are broken (this is on http://svn.modxcms.com/docs/display/Evo1/Creating+a+Template+Variable ). rolleyes

    After Googling this and not getting an answer, I went to IRC but the only other person there couldn’t figure this out either.

    My needs are fairly simple. I want to have a single template that depending on the value of the template variable, either does or doesn’t display the pagetitle within the content area.

    In my template, I have ’[*pgtitle*]’ within my page.

    My template variable has the following (relevant) settings:

    Template Variable Name: pgtitle
    Input Type: DropDown List Menu
    Input Option Values: Yes==<h3>[*pagetitle*]</h3>||No==<!-- no title -->
    Default Value: Yes
    Widget: none selected

    I have enabled my template within the Template Access section.

    When I go to the various pages within the site and choose either Yes or No within the drop-down list and save the page, there is no change in the page output or html output.

    I also tried changing to a checkbox, but cannot for the life of me figure out how to get that to work either.

    Help!



      • 3749
      • 24,544 Posts
      MODx is smart, but it’s not *that* smart. wink
      It has no way of knowing that you want that TV to control that content tag.

      There are many ways of doing what you want, but have you considered just using another field in the template (e.g. longtitle, description, introtext) and just leaving it blank on some documents? That would be the easiest way. pagetitle is one of the few fields that can’t be left blank.

      The next easiest way would be to change your template variable to a text input type, put the pagetitle in it, put [*pgtitle*] in the template in place of [*pagetitle*]. Then leave the TV blank on the pages where you don’t want it to show.

      You could also use your existing TV to control the visibility of the [*pagetitle*] field using PHX (this would be fairly inefficient).

      Another way would be to a create snippet that would either receive the TV value as a parameter or check it in code and output the pagetitle based on the TV setting.


        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting