Announcement

Collapse
No announcement yet.

Get CMS section in plugin code

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

  • [vB4] Get CMS section in plugin code

    I am trying to create a Tab for a specific CMS section. For this I am creating a plugin that adds the tab.

    My question: How do I check if the curent article belongs to a specific section?

    Its easy to check that I am in the CMS by using if (THIS_SCRIPT == 'vbcms') but what can I use to check for the category an article belongs to?

  • #2
    It seems that $sectionid is uses at some places, but I can not get it to work when I create a plugin using Process_templates_complete.

    Please anyone? How do I get the section id so it can be used in my tabs plugin?

    Comment


    • #3
      I've added code to the current code to make sure sectionid is available, but it's not in v403. You could attach something like this to the hook "vbcms_article_populate_end"

      global $sectionid;
      $sectionid = $this->content->getParentId();

      and to vbcms_section_populate_end if you like


      global $sectionid;
      $sectionid = $this->content->getNodeId();
      Please- I'm not tech support. Don't send your problem reports to me unless I've asked you to.

      Comment


      • #4
        Thank you very much, but I still have some trouble...

        I have created a plugin with hook location vbcms_article_populate_end and added the code:
        global $sectionid;
        $sectionid = $this->content->getParentId();


        Then I have a plugin with hook location process_templates_complete and there I have added the code:
        if ($sectionid == 3)
        {
        ......
        }

        But even though the sectionid is 3 I dont get into the "if" What Am I doing wrong?

        Comment


        • #5
          Originally posted by alfanexus View Post
          What Am I doing wrong?
          You missed the line where Edwin stated that this would not yet work in 4.0.3, but in the next version (i.e. 4.0.4).

          Comment


          • #6
            Oh crap, I understood it as I could make it global with this code in 4.03 and that it would be built in 4.04.

            Well I will then just have to wait another month or whenever 4.04 is released before I upgrade to Vbulletin 4 on my live site...

            If anyone has another solution that works right now please let me know, VB 4 has so many new great features I would like to introduce to my uses that is still on a vb 3.8 site

            Comment


            • #7
              Edwin suggested your would need to add two plugins. Did you add both?

              (I was under the impression that Edwin was offering that code as a fix *until* 4.0.4 came out. Perhaps I'm wrong.... (has been known to happen! ))

              Please don't PM or VM me for support - I only help out in the threads.
              vBulletin Manual & vBulletin 4.0 Code Documentation (API)
              Want help modifying your vbulletin forum? Head on over to vbulletin.org
              If I post CSS and you don't know where it goes, throw it into the additional.css template.

              W3Schools <- awesome site for html/css help

              Comment


              • #8
                Oh, but I may have misread it, too - didn't test. As Lynne, I've been wrong before, and I doubt it would be the last time

                Comment


                • #9
                  I haven't tested it either.

                  Please don't PM or VM me for support - I only help out in the threads.
                  vBulletin Manual & vBulletin 4.0 Code Documentation (API)
                  Want help modifying your vbulletin forum? Head on over to vbulletin.org
                  If I post CSS and you don't know where it goes, throw it into the additional.css template.

                  W3Schools <- awesome site for html/css help

                  Comment


                  • #10
                    At first I was also under the impression that Edwins offering was a fix *until* 4.0.4 came out. But I am not sure anymore.
                    What I did was creating a plugin with hook location vbcms_article_populate_end and added the code:
                    global $sectionid;
                    $sectionid = $this->content->getParentId();

                    This gets the section id alright (I have testet this by outputting the sectioned), and from my understanding $sectionid would now be a global variable that can be used any place. But when I create another plugin with with hook location process_templates_complete and try to use $sectionid the variable is just empty. So maybe something else ware is resetting the content of $sectionid;

                    Edwin also said that I could add the section id in vbcms_section_populate_end if I like, but in vb 4.03 there is no hook called vbcms_section_populate_end, so maby this will not work until 4.04 anyway?

                    I have searched for this all over vbulletin.com, vbulletin.org and google, and I see that others are asking the same, but havent fount any working solution yet

                    Comment


                    • #11
                      Is the hook located at process_templates_complete rendered before or after the hook located at vbcms_article_populate_end. If it is before, then it is not going to have the sectionid. You may need to try $GLOBALS['sectionid'] (but, of course, if the hook is run before, then that won't work either).

                      Please don't PM or VM me for support - I only help out in the threads.
                      vBulletin Manual & vBulletin 4.0 Code Documentation (API)
                      Want help modifying your vbulletin forum? Head on over to vbulletin.org
                      If I post CSS and you don't know where it goes, throw it into the additional.css template.

                      W3Schools <- awesome site for html/css help

                      Comment


                      • #12
                        Yes already tried to use $GLOBALS['sectionid']. But I diden't think about execution order of the hooks, this might be the problem, I don't know the order of them.

                        So I guess I am back to waiting for a solution in vb 4.04. Thanks for your effort

                        Comment


                        • #13
                          Okay I still struggle with this, since this might be a problem with execution order I guess that there is no guarantee that it will work in 4.04, so I have made a paid request here at vbulletin.org. If any one can help me then this might be a job for you: http://www.vbulletin.org/forum/showthread.php?p=2025843

                          Comment


                          • #14
                            Any update to this request ? (i'm in 4.0.4 and it still doesn't work)

                            I also need to get the sectionid info in my templates and can't figure of a way to make it works.

                            Comment


                            • #15
                              If I use vB::$vbulletin->nodeid in my plugin, hook: global_bootstrap_complete I get an php error:
                              Class 'vB' not found in /forum/includes/class_bootstrap.php

                              No I do a workaround via the ($_GET['r'] - but this isn't a clean solution.

                              Any update on this?

                              Comment

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