Announcement

Collapse
No announcement yet.

question of a newbie : how to display a phrase custom?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • question of a newbie : how to display a phrase custom?

    hello

    I'm new with vBulletin, I added a phrase in the phrase manager with the variable name legacy_xxx. How can I display the text contained in this variable in an html or php module?

    My vbulletin version is the latest: 5.4.4

    Forgive my English, but I am French and it is not easy for me.

    Best Regards.

    domdom


  • #2
    You can't use phrases in HTML modules. Well not easily. You would have to create a new login to the API and initialize it before you can retrieve phrases for use.

    Using a PHP Module, you would want to call the vB5 Temple Phrase class: http://vb5support.com/resources/api/...te_Phrase.html

    If you create a template in your style you can call the phrase using vBulletin Markup:

    Code:
    phrase
    {vb:phrase phrase_name[, arguments for phrase...]}
    
    Inserts the specified phrase. If arguments are provided, they will be run through htmlspecialchars.
    
    
    rawphrase
    {vb:rawphrase phrase_name[, arguments for phrase...]}
    
    As above, though arguments bypass htmlspecialchars.
    Of course templates are easiest. So you could create a custom template and then use the Template Display Module to put it on the screen. This gives you the benefits of the HTML module but access to the ability to pull variables and call API methods directly.
    Translations provided by Google.

    Wayne Luke
    The Rabid Badger - a vBulletin Cloud demonstration site.
    vBulletin 5 API - Full / Mobile
    Vote for your favorite feature requests and the bugs you want to see fixed.

    Comment


    • #3
      I had thought about creating a phrase because my site is multilingual. So, depending on the user's language, I could have the translation directly in the phrase among the configured languages.

      Using your method, can I retrieve the translations written in the phrase manager?

      Thank you for your answer. Regards.

      Comment


      • #4
        Originally posted by Wayne Luke View Post
        You can't use phrases in HTML modules. Well not easily.
        You can, using Javascript.

        Code:
        var phrase = vBulletin.phrase.get('phraseVariableNameHere');
        alert(phrase);

        GIPHY for vB5 AutoLinker Auto-Create Flag Report Topic Social Icons in Postbit Clear Cache Cron DragDrop Upload Topic AJAX AutoUpdate Custom Avatars Selector Stop Links in Posts...and more!

        Comment


        • Glenn Vergara
          Glenn Vergara commented
          Editing a comment
          But note that you have to wait for the page to be fully loaded (using window load event) in order to access the vBulletin js variable. It may not be available yet if you access it immediately from an HTML module.

      • #5
        I'm sorry, but I'm starting with vBulletin, and I don't know where to find the API, plus I created a custom template, but I don't know where, I have to put code and how to do it.

        Thank you for your help.

        Regards. domdom

        Comment


        • #6
          Originally posted by

          If you create a template in your style you can call the phrase using vBulletin Markup:

          [code
          phrase
          {vbhrase phrase_name[, arguments for phrase...]}

          Inserts the specified phrase. If arguments are provided, they will be run through htmlspecialchars.


          rawphrase
          {vb:rawphrase phrase_name[, arguments for phrase...]}

          As above, though arguments bypass htmlspecialchars.
          [/code]
          Hello,

          Can you explain to me what a vbulletin markup is?

          Thank you very much.

          Comment


          • #7
            It is code used within vBulletin's template to retrieve data such as variables, templates, and even other templates.
            Translations provided by Google.

            Wayne Luke
            The Rabid Badger - a vBulletin Cloud demonstration site.
            vBulletin 5 API - Full / Mobile
            Vote for your favorite feature requests and the bugs you want to see fixed.

            Comment


            • #8
              Hello,

              I tried to put this in a php module, but it doesn't work:

              <?php
              {vbhrase phrase};
              ?>

              Sorry for not understanding and not knowing how to do it.

              Comment


              • #9
                You can only use vBulletin Markup within vBulletin templates. In a PHP module, you would have to use the specific API call to pull the phrase from the database.

                The vBulletin API is documented here:http://vb5support.com/resources/api/...l#method_fetch
                Translations provided by Google.

                Wayne Luke
                The Rabid Badger - a vBulletin Cloud demonstration site.
                vBulletin 5 API - Full / Mobile
                Vote for your favorite feature requests and the bugs you want to see fixed.

                Comment


                • #10
                  Thank you for your answers.

                  Unfortunately, I can't do it, and I haven't found a tutorial that would allow me to do this work. There is very little help for beginners. I tried it with a hook in debug mode, but it didn't work.

                  If you had a tutorial to give me, I'd be really happy!
                  Best Regards.

                  Comment


                  • #11
                    I am sorry but we can't teach PHP as part of Support. You would use standard PHP and the vBulletin API within a PHP Module.

                    Create a new template...

                    Add your HTML to the template.

                    Add the phrases you want to use with this template inside your HTML.

                    Go to the page you want to display the code on.

                    Edit the page in Site Builder.

                    Drag the Template Display Module to the page.

                    Edit the options and set the name to the template that you created.

                    Translations provided by Google.

                    Wayne Luke
                    The Rabid Badger - a vBulletin Cloud demonstration site.
                    vBulletin 5 API - Full / Mobile
                    Vote for your favorite feature requests and the bugs you want to see fixed.

                    Comment

                    widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                    Working...
                    X