[Solved] Different plugins in different sidebars/areas?

Post Reply
User avatar
Torsten_Kelsch
Master Bludit
Posts: 140
Joined: Thu Aug 27, 2015 10:24 pm
Location: Germany
Contact:

Thu Feb 15, 2018 1:23 pm

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.
ON ERROR GOTO BED
User avatar
diego
Site Admin
Posts: 674
Joined: Sat May 16, 2015 2:53 pm
Contact:

Thu Feb 15, 2018 11:38 pm

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.
User avatar
Torsten_Kelsch
Master Bludit
Posts: 140
Joined: Thu Aug 27, 2015 10:24 pm
Location: Germany
Contact:

Mon Feb 19, 2018 9:58 pm

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?
ON ERROR GOTO BED
User avatar
diego
Site Admin
Posts: 674
Joined: Sat May 16, 2015 2:53 pm
Contact:

Tue Feb 20, 2018 5:33 pm

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();
?>
User avatar
Edi
Site Admin
Posts: 1193
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Contact:

Tue Feb 20, 2018 5:35 pm

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
Planet Bludit, Tipps, Snippets und nützliche Links. - Newsletter, Informationen zu Bludit (auf Deutsch).
User avatar
Torsten_Kelsch
Master Bludit
Posts: 140
Joined: Thu Aug 27, 2015 10:24 pm
Location: Germany
Contact:

Tue Feb 20, 2018 8:36 pm

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.
ON ERROR GOTO BED
User avatar
Edi
Site Admin
Posts: 1193
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Contact:

Tue Feb 20, 2018 9:01 pm

A solution is described here:

viewtopic.php?p=4630#p4630
Planet Bludit, Tipps, Snippets und nützliche Links. - Newsletter, Informationen zu Bludit (auf Deutsch).
User avatar
Torsten_Kelsch
Master Bludit
Posts: 140
Joined: Thu Aug 27, 2015 10:24 pm
Location: Germany
Contact:

Tue Feb 20, 2018 10:36 pm

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 …
ON ERROR GOTO BED
User avatar
Torsten_Kelsch
Master Bludit
Posts: 140
Joined: Thu Aug 27, 2015 10:24 pm
Location: Germany
Contact:

Tue Feb 20, 2018 10:40 pm

How can I mark this thread as solved? Or does a moderator have to do this?
ON ERROR GOTO BED
User avatar
Edi
Site Admin
Posts: 1193
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Contact:

Wed Feb 21, 2018 1:35 am

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.
Planet Bludit, Tipps, Snippets und nützliche Links. - Newsletter, Informationen zu Bludit (auf Deutsch).
Post Reply