Page 1 of 1

[Solved] Different plugins in different sidebars/areas?

Posted: Thu Feb 15, 2018 1:23 pm
by Torsten_Kelsch
I’d like to include different plugins, but not all in the same sidebar; instead, the About plugin in a sidebar or below the main content, and Edi’s new Navigation plugin in a header section. I read the post about sorting plugins: viewtopic.php?f=6&t=1068, but I still don’t know how to show only one of the activated plugins in one area. Is that possible anyway? Any ideas? Thanks in advance.

Re: Different plugins in different sidebars/areas?

Posted: Thu Feb 15, 2018 11:38 pm
by diego
Hi,
take a look to this doc, https://docs.bludit.com/en/developers/plugins
You can check different plugins if are activated and then print the sidebar on part of the theme where you like.

Re: Different plugins in different sidebars/areas?

Posted: Mon Feb 19, 2018 9:58 pm
by Torsten_Kelsch
I don’t understand it. I have a PHP file about.php, and another, navi.php. If I put the following code into about.php, for example, it gives me an error like below:

Code: Select all

<?php
    // Class name of the plugin
    $className = 'pluginAbout';

    // Get the Plugin-Object
    $plugin = getPlugin($className);

    Theme::plugins('pluginAbout')
?>
Notice: Undefined index: pluginAbout in /var/www/ud21_353/html/bl-kernel/helpers/theme.class.php on line 151

Warning: Invalid argument supplied for foreach() in /var/www/ud21_353/html/bl-kernel/helpers/theme.class.php on line 151


And if my code is as follows, all activated plugins appear on the web page:

Code: Select all

<?php
    // Class name of the plugin
    $className = 'pluginAbout';

    // Get the Plugin-Object
    $plugin = getPlugin($className);

    Theme::plugins('siteSidebar')
?>
(The difference is in the last line.)

But what I want is: the Navigation plugin on top of the page, and the About plugin on the bottom. What’s my mistake?

Re: Different plugins in different sidebars/areas?

Posted: Tue Feb 20, 2018 5:33 pm
by diego
I don't know where you get this code.

Code: Select all

<?php
    // Class name of the plugin
    $className = 'pluginAbout';

    // Get the Plugin-Object
    $plugin = getPlugin($className);

    Theme::plugins('pluginAbout')
?>
but the idea is this

Code: Select all

<?php
    // Class name of the plugin
    $className = 'pluginAbout';

    // Get the Plugin-Object
    $plugin = getPlugin($className);

    echo $plugin->siteSidebar();
?>

Re: Different plugins in different sidebars/areas?

Posted: Tue Feb 20, 2018 5:35 pm
by Edi
Torsten_Kelsch wrote: Mon Feb 19, 2018 9:58 pm

Code: Select all

<?php
    // Class name of the plugin
    $className = 'pluginAbout';

    // Get the Plugin-Object
    $plugin = getPlugin($className);

    Theme::plugins('siteSidebar')
?>
(The difference is in the last line.)

But what I want is: the Navigation plugin on top of the page, and the About plugin on the bottom. What’s my mistake?
There must be a Helper in the Theme for the Hook of the plugin:

https://docs.bludit.com/en/themes/helper-for-themes

https://docs.bludit.com/en/plugins/hooks-list

Re: Different plugins in different sidebars/areas?

Posted: Tue Feb 20, 2018 8:36 pm
by Torsten_Kelsch

Code: Select all

<aside>
	<?php
		Theme::plugins('siteSidebar');
	?>
</aside>
This is the helper, right? It works, but will show every activated plugin. But I’d like to have the Navigation plugin in the horizontal navigation bar (nav), and the About plugin in an area below the main content (aside) – not all of the activated plugins in the same area. Is that possible anyway?

Or you could also imagine a website with two sidebars, one on the left, one on the right beside the main content.

Re: Different plugins in different sidebars/areas?

Posted: Tue Feb 20, 2018 9:01 pm
by Edi
A solution is described here:

viewtopic.php?p=4630#p4630

Re: Different plugins in different sidebars/areas?

Posted: Tue Feb 20, 2018 10:36 pm
by Torsten_Kelsch
Finally I could solve my problem!
Edi wrote: Sat Jan 13, 2018 1:18 am viewtopic.php?p=4630#p4630
Thank you so much, Edi, this works fine for me :D . Now I have a file php/about.php with the following code:

Code: Select all

<?php
	if( $plugins['all']['pluginAbout']->installed() ){
		echo '<h3 class="plugin-label">'.$plugins['all']['pluginAbout']->getValue('label').'</h3>';
		echo html_entity_decode(nl2br($plugins['all']['pluginAbout']->getValue('text')));
	}
?>
And another file called php/navi.php with the code:

Code: Select all

<?php
	if( $plugins['all']['pluginNavigation']->installed() ) {
		echo '<h3>'.$plugins['all']['pluginNavigation']->getValue('label').'</h3>';
		echo'<ul class="menu">';

        // Foreach parent-page
		foreach ( $pagesByParent[PARENT] as $Parent ) {
			echo '<li'.( ($Parent->key()==$Url->slug())?' class="active"':'').'><a href="'.$Parent->permalink().'">'.$Parent->title().'</a></li>';
		}		
		echo '</ul>';
	}
?>
And in my index.php I include both of them in different areas:

Code: Select all

<nav>
	<div class="navi">		
		<?php include(THEME_DIR_PHP.'navi.php'); ?>	
	</div>				
</nav>

Code: Select all

<div class="content">
	<aside>
		<?php
			include(THEME_DIR_PHP.'about.php');		
		?>
	</aside>
</div>
It’s so easy if you know how to do it. And as soon as you do it right, it works …

Re: Different plugins in different sidebars/areas?

Posted: Tue Feb 20, 2018 10:40 pm
by Torsten_Kelsch
How can I mark this thread as solved? Or does a moderator have to do this?

Re: Different plugins in different sidebars/areas?

Posted: Wed Feb 21, 2018 1:35 am
by Edi
Torsten_Kelsch wrote: Tue Feb 20, 2018 10:40 pm How can I mark this thread as solved? Or does a moderator have to do this?
Editing the subject of the first post.

I have done it.