We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25551 ☆ A M B ☆
    • 1,231 Posts
    I need some ideas on how to populate a TV on a page using a field from the database.

    I tried

    @SELECT id, usertags FROM modx_my_data 


    But this code doesn’t actually put the info from the id and usertags in the tv, instead it puts the @SELECT... code in instead. The info does display if I put the [*UserTags*] TV call in to the body of the page so it is reaching the database at least. I have the user being able to input data into a table and I would like to be able to return the text and populate the TV. I want it to show "MY TAGS" instead of the @SELECT... code.

    Is this possible?

      Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
      AugmentBLU - MODX Partner

      BLUcart - MODX Revolution E-Commerce & Shopping Cart
      • 4310
      • 2,310 Posts
      Ross,
      Have you thought about using the data grid widget for display?
        • 25551 ☆ A M B ☆
        • 1,231 Posts
        I have but this does not populate the TV in a document. I need the text from the usertags field to show in the TV in the manager. I want to extend this to use with a tagcloud as the tagcloud links are produced based on a TV value for a document. I managed to get it working if you were on the actual page that had the tags but if you navigated away the tags disappear from the cloud... it’s cos the info in the TV is only being pulled when on the page, I need the TV to be able to take a value from the database and store the value in the TV as default so the cloud can pick up the TV value when on other pages.

        I managed to have this working with FDM, I used FDM to allow a webuser to fill a TV with tags of their choice which worked perfectly... I now have changed the way users edit their profiles so I do not use FDM.

        Cheers
          Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
          AugmentBLU - MODX Partner

          BLUcart - MODX Revolution E-Commerce & Shopping Cart
          • 26903
          • 1,336 Posts
          Could you not write a snippet, called from that page, that runs your query then writes its output into the default value field of ypur TV? That way when you enter that page the TV will be set and remain set until changed again.
            Use MODx, or the cat gets it!
            • 25551 ☆ A M B ☆
            • 1,231 Posts
            I will give some ideas a shot tomorrow... my brain is not working just now lol.

            I have given the user the ability to add tags to their user profile in webloginPE... it’s inserted in to the modx_web_user_attributes_extended table and is stored as plain text.

            The user has their own page that is unique to them and their profile details are displayed on this page. I am using the TVtagcloud snippet on the site and I want to allow the uers tags that is stored in the modx_web_user_attributes_extended table to display in the tagcloud. The way the snippet works is it tags keywords from a TV and links are put in the tag cloud which then relates to documents that share the same tag... I want the users tags to be included in the cloud and the way I want it to work is by inserting the usertags from the database in to the TV of their page so that their custom tags relates to their page in the tag cloud.

            If the user updates their profile usertags I would like the tv on their page to be updated as well.

            @SELECT usertags FROM modx_web_user_attributes_extended shows usertags from all profiles if use with a TV and delimited list selected, I have to manually select the relevant tags to the user and save the document... that then allows the usertags to appear in the tagcloud, how do I auto select the tags relevant to the document creator. I am a beginner with PHP so i’m unsure what to do next, I may go back to using FDM for this specific task if I can’t figure it out.

            Thanks!
              Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
              AugmentBLU - MODX Partner

              BLUcart - MODX Revolution E-Commerce & Shopping Cart
              • 25551 ☆ A M B ☆
              • 1,231 Posts
              Anyone got a rough idea what I’m trying to do and a possible solution?
                Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
                AugmentBLU - MODX Partner

                BLUcart - MODX Revolution E-Commerce & Shopping Cart
                • 28000 ☆ A M B ☆
                • 397 Posts
                Was this solved? I would like a similar solution!
                  Benjamin Davis: American web designer living in Munich, Germany and a MODX Ambassador. I am also co-founder of SEDA.digital, a MODX Agency.