Announcement

Collapse
No announcement yet.

Global variable in vB5

Collapse
X
Collapse
First Prev Next Last
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Global variable in vB5

    Hello!
    The problem is this: I need to output my variable anywhere in the template. The variable will receive a value from the database via a sql query. The question is: where do I need to declare this variable and how to make it so that I can display it in a template, like this: {vb: raw my_custom_variable}.
    I create a product by the instructions in the core / packages folder, created a class there, etc. Tell me how to do it further so that my variable can be displayed later in the template. On the forums I found information that I need to do this, but it does not work, or I do it wrong:
    $topheaderbar = 'my_data_from_database';
    vB_Template::preRegister('header',array('topheaderbar' => $topheaderbar));
    I really need help !!! Thank you!

    #2
    I posted this How to create vB5 mod blog from a vB Support staff in the Useful Links module on the homepage here.



    Basically, you will add the variable to the global $page array.
    Helpful? Donate. Thanks!
    Buy me a coffeePayPal QR Code
    Fast VPS Host for vBulletin:
    A2 Hosting & IONOS

    Comment


      #3
      Thank you so much! Happened! I could not at first understand what kind of variable hwWorld, now I realized that we add it to the array $page! Thanks again!

      Comment


        #4
        Tell me one more thing:
        In the response form template, I added a hidden field to the form sending a response on the "enemy_field" forum. Screenshot: https://i.imgur.com/X8elj32.jpg
        Now I want to send a value or other data associated with this field using the $_POST method. But the problem!
        If in the root folder in index.php I include include 'my_custom_file.php'; and it receives $_POST ['enemy_field'] then everything works. But this is inconvenient, because when updating the file index.php will change and will have to re-include the file include 'my_custom_file.php';
        And when I try to get $_POST ['enemy_field'] in my plugin /packages/my_plugin/api/page.php, it feels like my plugin does not get it and my idea does not work. I understand that internal vBulletin files and plugins are protected from receiving and passing _POST inside the engine. Is there any way to enable this or can I use some other method of receiving this POST request? Thanks in advance for the answer !!!

        Comment


          #5
          Try extending the add() function in the content API instead of fetchPageById() in the page API. The add() function is called when submitting a post and from there you might be able to get the POST data.
          Helpful? Donate. Thanks!
          Buy me a coffeePayPal QR Code
          Fast VPS Host for vBulletin:
          A2 Hosting & IONOS

          Comment

          Users Viewing This Page

          Collapse

          There is 1 user viewing this forum topic.

          • Guest Guest

          Latest Posts

          Collapse

          Working...
          X
          Searching...Please wait.
          An unexpected error was returned: 'Your submission could not be processed because you have logged in since the previous page was loaded.

          Please push the back button and reload the previous window.'
          An unexpected error was returned: 'Your submission could not be processed because the token has expired.

          Please push the back button and reload the previous window.'
          An internal error has occurred and the module cannot be displayed.
          There are no results that meet this criteria.
          Search Result for "|||"