Posted on: 12/11/04 07:12pm
By: machinari
like blaine is testing on this site with his forum plugin, I would like to make a menu appear amongst the left blocks when my dailyquote plugin is in the fore.
I've done it... and it works... but I don't know if I've done it the way it should have been done and/or the way
Blaine mentioned[*1] that it could be done in 1.3.10.
here is what I did:
*created a phpblock
without a topic id (so it doesn't show up without being called by the plugin).
*in another function, dqmenu(), which returns formatted blocks, I passed the phpblock name in an array to custom_showBlocks($array) and followed up with COM_showBlocks('left',$topic).
* I passed the name of the dqmenu() function in an array to COM_siteHeader on my plugin pages.
My question is... Is that the proper way to get a plugin menu into the left blocks? ...Or did I just get lucky?
plugin block menu in 1.3.10
Posted on: 12/11/04 11:23pm
By: Blaine
Machinari,
I think thats a little different then I had intended but good show for exploring this new plugin feature. This was somethign I added to GL 1.3.10 after work on other plugins and we have just started to explore how we can use this more flexible block formatting.
Are you just wanting to display the one block or like shown here, I display the forum nav block on top of what ever the user already should be seeing - if you turn off certain blocks in your preferences, it will no longer show as well when in the forum.
I call COM_siteHeader like this:
echo COM_siteHeader( array('custom_showBlocks',$CONF_FORUM['leftblocks']) )
The function custom_showBlocks is in the provided GL1.3.10 lib-custom and it includes example of how to use it.
The array $CONF_forum['leftblocks'] can be customized by the site admin in my case or by dedault, will build an array of the blocks you should see on the left and then add the forum nav block as the first item.
plugin block menu in 1.3.10
Posted on: 12/11/04 11:26pm
By: Blaine
Oh and I just mark the block as "disabled" so it will not show. The other idea is to create a topic called "hidden" or something else and assign it to that topic. Just set the access so that no one will see that topic.
The function custom_showBlocks does not restrict the query to only enabled blocks so your plugin block will be found.
plugin block menu in 1.3.10
Posted on: 12/12/04 12:58am
By: machinari
[QUOTE BY= Blaine] Are you just wanting to display the one block or like shown here[/QUOTE]I want to display my block just like you've done here--on top of the usual left blocks.
[QUOTE BY= Blaine]if you turn off certain blocks in your preferences, it will no longer show as well when in the forum.[/QUOTE]not sure i'm following you there. why would turning off one block affect any other?
anyway, this is how i called COM_siteHeader:
//returns the formatted dq menu block and then then the usual left blocks
function dqmenu(){
$a = array('dqmenu');//dqmenu is the name of the phpblock
$retval = custom_showBlocks($a);
$retval .= COM_showBlocks( 'left', $topic );
return $retval;
}
$dqblockmenu = array(dqmenu);
//here, dqmenu represents the function name recognized by COM_siteHeader as a plugin function
COM_siteHeader($dqblockmenu);
it works very nicely though I could probably do it in a couple less lines.
[QUOTE BY= Blaine]The function custom_showBlocks does not restrict the query to only enabled blocks so your plugin block will be found.[/QUOTE]Actually, my 1.3.10 lib-custom shows that custom_showBlocks does restrict the query to only enabled blocks in the where clause--assuming that '1' equals enabled,
plugin block menu in 1.3.10
Posted on: 12/12/04 01:03am
By: Blaine
[QUOTE BY= machinari]Actually, my 1.3.10 lib-custom shows that custom_showBlocks does restrict the query to only enabled blocks in the where clause--assuming that '1' equals enabled,[/QUOTE]
Are you sure you are not running a pre-final version as I removed that restriction.
plugin block menu in 1.3.10
Posted on: 12/12/04 01:06am
By: Blaine
[QUOTE BY= machinari] Not sure i'm following you there. why would turning off one block affect any other?[/QUOTE]Users have the option to disable certain blocks in their userprefs so maybe for example I don't want to see the Resources Block anymore. I would then not want to see it again if I am in a plugin that us controlling the leftblocks.
plugin block menu in 1.3.10
Posted on: 12/12/04 01:14am
By: Blaine
com_siteHeader is expecting an array that contains 2 parms, the custom function for formatting the blocks and an parm to pass to the custom function. Since your function has no parms then I guess that's fine. It could still be done in a few less lines but there are multiple ways to do this.
I was using this in a CMS plugin where the user could specify a list of blocks to show for a particular page. So it needed to be very flexible as each page could be requesting different blocks on the left and right side.
plugin block menu in 1.3.10
Posted on: 12/12/04 02:53am
By: machinari
[QUOTE BY= Blaine]Are you sure you are not running a pre-final version as I removed that restriction.[/QUOTE]whoops.. you're right, it was rc1.
[QUOTE BY= Blaine]Users have the option to disable certain blocks in their userprefs so maybe for example I don't want to see the Resources Block anymore. I would then not want to see it again if I am in a plugin that us controlling the leftblocks.[/QUOTE]I understand. but the way I have it, the plugin's control of the blocks allows for GL's control of any blocks after the plugin's block or blocks by using com_showblocks rather than a configurable array of blocks as the 2nd parm. does that make sense?
[QUOTE BY= Blaine]com_siteHeader is expecting an array that contains 2 parms, the custom function for formatting the blocks and an parm to pass to the custom function.[/QUOTE]I didn't even think to do it that way.
anyway, too much learning curve for one night. and I neglected to mention that I think this little feature is quite amazing. It makes the plugin's integration into the cms so much more obvious.
nice work Blaine
plugin block menu in 1.3.10
Posted on: 12/12/04 03:29am
By: machinari
I'm looking at the final 1.3.10 lib-custom, which I should have done in the first place, and I see the instructions provided.
lol I did this from the rc1 copy and no instructions. so I guess I can answer my initial question--I did get lucky. now i'll go do it right.
plugin block menu in 1.3.10
Posted on: 12/12/04 09:36am
By: remy
This is what I did in 1.3.8, which does work in 13.9 as well:
Create a topic named 'plugin_topic_1' and degrade access to it for Admin only. So nobody can see it.
Assign the proper blocks to this topic.
Add a line to the plugin-modules saying '$topic="plugin_topic_1";' before anything is loaded.
This addition make GL think the topic is 'plugin_topic_1' and GL displays left and right blocks for this topic. You might even write an article under this topic, having it shown when your plugin is called. Refer f.i. to www.php.net having a similar structure (using user-articles at the end of the page).
An example can be seen at www.mycobol.net. Go to the glossary plugin. and notice some searching blocks appear to the left.