HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How might I conditionally add a module in my plugin?

ddumontddumont ✭✭

I don't want it added in the dashboard... My dashboard is getting a bit cluttered already.

There was an error rendering this rich post.

Best Answer

  • peregrineperegrine MVP
    edited July 2012 Answer ✓

    i've got no thoughts on other way. what you said.

      if (!preg_match('/dashboard/',$Sender->SelfUrl))
                  $Sender->AddModule("SubscribeModule");
    
    

    get the buttonbar back - it was much easier to paste code.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Answers

  • Wow, it's a good question, but also I need a bit of more information. Can you write out the conditions in semi-code? Also in which events to you want to add those modules? I was more thinking 'Smarty' then 'plugin' with your title, if you know what I mean.

    There was an error rendering this rich post.

  • public function Base_Render_Before($Sender) {
        ...
        if (/* not dashboard */) {
            $Sender->AddModule("SubscribeModule");
        }
        ...
    }
    

    If that makes any sense. I have a plugin, and it's placing a module in this way, so I'm looking for a condition to wrap it in. If you have a better way of doing it, I'm all ears.

    There was an error rendering this rich post.

  • Looks good to me, I don't know my way around plugins yet though. Maybe @Peregrine and @x00 know more to say about this one.

    There was an error rendering this rich post.

  • peregrineperegrine MVP
    edited July 2012 Answer ✓

    i've got no thoughts on other way. what you said.

      if (!preg_match('/dashboard/',$Sender->SelfUrl))
                  $Sender->AddModule("SubscribeModule");
    
    

    get the buttonbar back - it was much easier to paste code.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Thanks @peregrine, the SelfUrl was exactly what I was looking for.

    There was an error rendering this rich post.

  • glad I could help someone who could code circles around me :).

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • ToddTodd Vanilla Staff

    As an FYI, in 2.1 we have an InSection() function which will allow you to call:

    if (!InSection('Dashboard')) {
       ...
    }
    
  • oh, nice.

    There was an error rendering this rich post.

  • @Todd, are you nearing a 2.1 beta or rc build? Or are you teasing me?

    There was an error rendering this rich post.

  • ToddTodd Vanilla Staff

    We are nearing a 2.1 beta, but probably still a month or so away.

  • Hehe, cool. I'm looking forward to it.

    There was an error rendering this rich post.

  • ddumont said:
    Hehe, cool. I'm looking forward to it.

    you must be special to get the answer on that one. :)

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • @peregrine I guess :)

    I try to help out where I can, though php is not my favorite and I don't know it that well.
    (If the nilla folks are ever interested in doing a java port with OSGi plugins and stuff... I would totally be a huge contributor to that. I really think it could solve a ton of the problems with translations and stuff)

    le sigh... Maybe @Todd just think's my bird is cute (he's not wrong)

    There was an error rendering this rich post.

  • ToddTodd Vanilla Staff

    Alright, alright. Thread closed. Move along.

This discussion has been closed.