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

    I want to use a template variable which i can use to put secondary content into. This has to work individually for every document in the document tree.

    For this purpose i created a template variable in the "manage ressources" -> "template variables" part of the modx manager. Into its variable name field i entered: sidecontent. Into the caption field i entered: [*sidecontent*]. I entered a description and selected "Text" as an input type. Also i entered the following default value: This is the default. Finally i allowed the only template i am currently using to access/process the variable.

    In the html template i retrieve the content of the template variable by using "[*sidecontent*]" in a div i placed for it. Now if i load an arbitrary page that uses this template i can see the output of the default value in the sidecontent.

    The problem is though that i don’t seem to be able to actually edit the template variable for each page individually.
    I do get an editor for it in the "Template Variables" part below the document but if i make changes to it does not get saved together with the page. Instead i see the default value appear if i edit the page again or show it from the frontend.

    Am i missing something? How do template variables get saved? I have tried to use template variables of both richtext and text type but i keep getting only the default value i entered sad
      • 17883
      • 1,039 Posts
      hmmm, I don´t see something wrong in your description. Which version are you using? 0.921 or 0.92?
        • 36805
        • 354 Posts
        Quote from: MadeMyDay at Jul 18, 2006, 12:48 PM

        hmmm, I don´t see something wrong in your description. Which version are you using? 0.921 or 0.92?

        I am using MODx 0.9.2.1 (rev 1005)
          • 17883
          • 1,039 Posts
          strange, but:

          Into the caption field i entered: [*sidecontent*]

          Here you have to enter a description of the TV (like "content for the sidebar", but this shouldn´t have caused the behaviour.

          What happens if you don´t set a default value? Can you then store something? Did you try a reinstall?

          • I have noticed in some installations that I’m working with that sometimes I have to save a page three and four times before the edited TV value is actually saved. I haven’t been able to deliberately trigger this behavior, and it doesn’t happen often enough to be able to really "put my finger on it", but it is really annoying when it happens. All of the sites in question are 0.9.2.1 installations that otherwise give me no trouble. I am still trying to figure out when this happens, and if it’s always on the same host.
              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
              • 36805
              • 354 Posts
              Quote from: MadeMyDay at Jul 18, 2006, 07:30 PM

              strange, but:

              Into the caption field i entered: [*sidecontent*]

              Here you have to enter a description of the TV (like "content for the sidebar", but this shouldn´t have caused the behaviour.

              What happens if you don´t set a default value? Can you then store something? Did you try a reinstall?



              I figured the caption field entry is a bit strange and now that i saw where it is used in the ressource manager i realise that I picked a misleading name. The confusion on my part was created by the example in the documentation ( http://modxcms.com/creating-a-template-variable.html ). It uses a [* ... *] tagged name in the caption field. This is a bit confusing and could maybe be replaced with a more practical example later on since it isn’t too clear in overall either.

              I tried to remove the default value as you suggested. Still nothing is stored in that case. I have not tried a reinstall yet but i will try that as soon as i find the time.

              Thanks for the replies so far. And keep up the good work on this marvellous CMS! smiley

              EDIT1: I unexpectedly had the time immidiately so i reinstalled and set up a minimal page with a similar sidecontent TV. Unfortunately it didn’t help

              EDIT2: PS: Just in case: the site is currently running locally on a WAMP installation on the Windows XP Home OS, i tested it with IE 6 and FireFox 1.5.0.4.
                • 36805
                • 354 Posts
                I revisited the project and the template variable saving issue which is unfortunately persistent.
                I have tried another install of modx of mine situated on a remote host and "over there " it works fine.

                So either this is a really weird modx bug or more likely: a problem with my local wamp setup.

                I am running WAMP5 Version 1.6.4 on Windows XP Home, if anyone has any suggestions on how i might find out what is going on i’d be glad to read them.

                EDIT: When trying to edit the TV using Quickedit from the frontend at least I got an error message. It might help resolving the issue. How can i make ModX create this database table for me? The ModX setup script succeeded in creating the database for me on installation and everything but writing back the TV’s works fine.
                Alternatively, if i would create the table myself, what should the MySQL command be? I’ll try any suggestions. Please help!

                The error message was:

                « MODx Parse Error »
                MODx encountered the following error while attempting to parse the requested resource:
                « Execution of a query to the database failed - Table ’modxdb.modxdb_’ doesn’t exist »
                SQL: UPDATE modxdb_ SET editedon=’’,editedby=’1154012704’ WHERE id = ’1’;
                [Copy SQL to ClipBoard]

                Parser timing
                MySQL: 0.0028 s s (4 Requests)
                PHP: 1154012704.7871 s s
                Total: 1154012704.7899 s s
                  • 36805
                  • 354 Posts
                  I switched to XAMPP for running the modx site locally. Since then it works like a charm.
                  Sorry for asking for support on this one, it turned out it is not really modx related.

                  Anyway i thought i should report this back since maybe it can help others with chosing a modx-suitable desktop webserver package smiley