Welcome to Geeklog, Anonymous Saturday, November 23 2024 @ 02:56 pm EST

Geeklog Forums

plugin block menu in 1.3.10


Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
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 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?
 Quote

Status: offline

Blaine

Forum User
Moderator
Registered: 07/16/02
Posts: 1232
Location:Canada
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:
Text Formatted Code
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.
Geeklog components by PortalParts -- www.portalparts.com
 Quote

Status: offline

Blaine

Forum User
Moderator
Registered: 07/16/02
Posts: 1232
Location:Canada
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.
Geeklog components by PortalParts -- www.portalparts.com
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
Quote by Blaine: Are you just wanting to display the one block or like shown here
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.
not sure i'm following you there. why would turning off one block affect any other?

anyway, this is how i called COM_siteHeader:
Text Formatted Code
//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.
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

Status: offline

Blaine

Forum User
Moderator
Registered: 07/16/02
Posts: 1232
Location:Canada
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,

Are you sure you are not running a pre-final version as I removed that restriction.
Geeklog components by PortalParts -- www.portalparts.com
 Quote

Status: offline

Blaine

Forum User
Moderator
Registered: 07/16/02
Posts: 1232
Location:Canada
Quote by machinari: Not sure i'm following you there. why would turning off one block affect any other?
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.
Geeklog components by PortalParts -- www.portalparts.com
 Quote

Status: offline

Blaine

Forum User
Moderator
Registered: 07/16/02
Posts: 1232
Location:Canada
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.
Geeklog components by PortalParts -- www.portalparts.com
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
Quote by Blaine:Are you sure you are not running a pre-final version as I removed that restriction.
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.
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? Confused
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.
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
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
Big Celebration
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.
 Quote

Status: offline

remy

Forum User
Full Member
Registered: 06/09/03
Posts: 162
Location:Rotterdam & Bonn
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.
 Quote

All times are EST. The time is now 02:56 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content