Announcement

Collapse
No announcement yet.

Earliest place and code to take pageid

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

  • Earliest place and code to take pageid

    In vb4 we had THIS_SCRIPT - it was working great. Not it is gone. The replacement is pageid, BUT:
    1. It is not easy to get (if it is please give me the method to get it)
    2. It is not alvays available - often I get 0, because I'm asking too fast for it, anf vB5 didn't initiate some thing yet (I got route with empty data)
    3. pageid is not human readable so it is pain in the ass.

    So - how can it be easily taken (please give code) and where it the EARLIEST place I can use it in plugins. I can tell that it is SOMETIMES working fine in state.php. And vB gives empty route in route.php, node.php (this is not always used because of cache), options.php... You made things so complicated for no reason. Or at least I do not know the right way to take pageid always appropriatelly and where I want to...

    The code I'm using is taken from vB5 code (I add my own global to make thinks easier, but I have issues I described above). It is added in plugin state.php, outside any class, so it is executed when plugin is loaded:
    Code:
    if (!defined('VBET_PAGEID')) {
        $router = vB5_ApplicationAbstract::instance()->getRouter();
        if ($router) {
            print_log("ROUTER: ". print_r($router, true));
            $arguments = $router->getArguments();
            $pageid = (int) (isset($arguments['pageid']) ? $arguments['pageid'] : (isset($arguments['contentid']) ? $arguments['contentid'] : 0));
            DEFINE('VBET_PAGEID', $pageid);
        }
    }
    Often I get 0, and often I need to ask for VBET_PAGEID before the plugin is loaded, but earlier plugins give empty router (print_log is my own function, so I can see what I got).
    I made also function to load pageid ad hoc, but of course mostly I got there empty router and pageid is 0, even when it really isn't...

    Can you make any easy way to determine the page like it was with THIS_SCRIPT? Can it be human readable? Can you give me solution for working with pageid in actual form in vB5?
    vBulletin Enterprise Translator (vBET) - your forum in 52 languages!

  • #2
    In javascript
    Code:
    pageData.pageid
    In Templates
    HTML Code:
    {vb:raw page.pageid}
    You should look into some mods and learn how to use the API and call your code from any template (template-hook)!
    Last edited by delicjous; Mon 11th Feb '19, 10:43am.
    vBulletin-forum.de | Das deutschsprachige vBulletin 5 Forum! | Widgets, Mods und Anleitungen auf deutsch.
    Latest Profile-Visitors, Disable-Postcount, Auto-close Threads, Latest Likes, Top-Posters, FavIcon Notifications, Memberlist-Name-Search, New&Free: vB5 MemberMap

    Comment


    • #3
      As I was wrting I need to take it in plugin code. Not in javascrip, not in template, but in plugin code. As fast as it it possible with predictable results. I gave you php code and in answer I got javascipt and template... Please read carefully what the post is about and if you able give me answer to my issue. I will appreciate answer to the issue, not to similar well known topics. I need to take pageid in PHP as soon as possible with predictable results (no matter what request I made I will get correct result, without any hazard like it is now, because vb5 is giving sometimes empty route - object with empty all attribites). Sorry if I made my question too complicated to understand.
      vBulletin Enterprise Translator (vBET) - your forum in 52 languages!

      Comment


      • #4
        You should assume that the variable is not available in your plugin. You should retrieve it in your code using the API provided. Variables should not be set as Global.

        http://vb5support.com/resources/api/vB5_Route_Page.html
        Translations provided by Google.

        Wayne Luke
        The Rabid Badger - a vBulletin Cloud customization and demonstration site.
        vBulletin 5 Documentation - Updated every Friday. Report issues here.
        vBulletin 5 API - Full / Mobile
        I am not currently available for vB Messenger Chats.

        Comment


        • #5
          Iam sorry trying to help. I will never waste your time again ;-)
          vBulletin-forum.de | Das deutschsprachige vBulletin 5 Forum! | Widgets, Mods und Anleitungen auf deutsch.
          Latest Profile-Visitors, Disable-Postcount, Auto-close Threads, Latest Likes, Top-Posters, FavIcon Notifications, Memberlist-Name-Search, New&Free: vB5 MemberMap

          Comment


          • In Omnibus
            In Omnibus commented
            Editing a comment
            His questions are way beyond the scope of normal support in any case so I appreciate your trying to help even if he doesn't.

        • #6
          Originally posted by Wayne Luke View Post
          You should assume that the variable is not available in your plugin. You should retrieve it in your code using the API provided. Variables should not be set as Global.

          http://vb5support.com/resources/api/vB5_Route_Page.html

          If I should assume that it is not available, then why you are writing, that I should retrieve it? This has no sense. To retrieve it, it has to be available. And that is what I'm asking about, how amd where retrieve it as fast as possible in plugin code (not in template or JS - this is already too late). You write to use API provided - I'm getting it using API. I gave you code, where you can see your API is used. But your API is buggy - sometimes gives wrong results. That is why I'm asking for help. The answer you gave is inconsistent and it doesn't answer the question. Also link to documentation, you gave, tells nothing about pageid.
          vBulletin Enterprise Translator (vBET) - your forum in 52 languages!

          Comment


          • #7
            Assuming means there is a variable prefilled and available to your plugin. You're assuming that getroute has the information that you need. However it might not at that point in execution.

            Retrieving is using the API to make calls to the routing functions in order to retrieve the proper page id and assigning it to variable in your plugin.

            They are completely different things. Your code snippet doesn't provide enough context to answer your question directly.
            Translations provided by Google.

            Wayne Luke
            The Rabid Badger - a vBulletin Cloud customization and demonstration site.
            vBulletin 5 Documentation - Updated every Friday. Report issues here.
            vBulletin 5 API - Full / Mobile
            I am not currently available for vB Messenger Chats.

            Comment

            Related Topics

            Collapse

            Working...
            X