We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23054
    • 62 Posts
    In my project I stored a lot of data in own tables within modx database.
    So I would like to change the title of a page given in MODx manager by querying my data table ?

    How can this be done ?
      • 11975
      • 2,542 Posts
      HI,

      I suppose that you could use TV for this.
      Create a TV called : externalTitle (ListBox single select)
      in option values : use @SELECT mytitle,myid from myTable where ... -> to query your table
      In your template: Change [*longtitle*] to [* externalTitle*]

      :-)
        Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
        • 23054
        • 62 Posts
        The idea is good, but that is not what I am looking for.

        I just need for some documents the page title to be changed - so it should be easier to overwrite this somewhere instead of creating new templates for that case.

        What I need is to know where and how during the parsing process I can change the documents (page)title according to my data base values.

        Ok, solved meanwhile: Created an plugin with that source code
        $modx->documentObject['longtitle'] = ..
        $modx->documentObject['pagetitle'] = ...


        Anyway - can I assign this plugin just to certain sites ?
          • 7923
          • 4,213 Posts
          Ok, don’t know what you have done allready, but one way would be by making the TV like heliotrope said. Then make a plugin what replaces the title if the document has that TV and something is selected in it.. Or make a checkbox TV and in plugin, check if document has that TV and is it checked.


            "He can have a lollipop any time he wants to. That's what it means to be a programmer."
            • 22815
            • 1,097 Posts
            It looks like the answers thus far have concentrated on changing the page output to have a different title.

            But the top post says "the title of a page given in MODx manager". So persepolis, is it just public title display that you want to change, or do you need the page titles in the manager to change also? And is this a one-time change? Does one MODx page display different data depending on other variables?
              No, I don't know what OpenGeek's saying half the time either.
              MODx Documentation: The Wiki | My Wiki contributions | Main MODx Documentation
              Forum: Where to post threads about add-ons | Forum Rules
              Like MODx? donate (and/or share your resources)
              Like me? See my Amazon wishlist
              MODx "Most Promising CMS" - so appropriate!
              • 23054
              • 62 Posts
              Quote from: PaulGregory at Jul 17, 2006, 08:34 AM

              It looks like the answers thus far have concentrated on changing the page output to have a different title.

              But the top post says "the title of a page given in MODx manager". So persepolis, is it just public title display that you want to change, or do you need the page titles in the manager to change also? And is this a one-time change? Does one MODx page display different data depending on other variables?


              Hello Paul,

              the idea is to store a lot of companies data within my own tables.
              These data are used outside of the CMS too.
              So if the official name of a department changes the changes have to be reflected by the web sites - the easiest way is to retrieve the data from my tables instead of changing the page titles within MODx too.
              Actually within MODx the titles for the department sites are not really important (but for the other sites, therefore the template contains the code
              <h1>[*pagetitle*]</h1>

              )
              I hope I exlained that clearly.

              I think my way works fine - it is just ugly to query the database for every web site. Actually there might be 100 sites and maybe 20 departments, so narrow the plugin just to the sites needed would be good

              Holger
                • 7923
                • 4,213 Posts
                You could cache the pages and do a site refresh anytime you need the titles to change..


                  "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                  • 34162
                  • 1 Posts
                  I think you could create a TV which contains the key to access the current title in the foreign table. (Default "0" i.e. the title just remains as it is, since no key for the foreign table is provided.)
                  Then you create a plugin to update the real pagetitles according to those tv/key-values, using the method you have found ($modx->documentObject[’pagetitle’] = ...) in a loop.
                  Doing so you have the current title as a normal title in the manager and you can update them only when needed by executing the module from within the manager. So you don’t have to query the table each time a page is rendered.

                  Hope it may help.