[Solved] Different plugins in different sidebars/areas?

Post Reply
User avatar
Torsten_Kelsch
Legend Bludit
Posts: 263
Joined: Thu Aug 27, 2015 10:24 pm
Location: Germany
Has thanked: 4 times
Been thanked: 2 times
Contact:

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: 773
Joined: Sat May 16, 2015 2:53 pm
Been thanked: 1 time
Contact:

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
Legend Bludit
Posts: 263
Joined: Thu Aug 27, 2015 10:24 pm
Location: Germany
Has thanked: 4 times
Been thanked: 2 times
Contact:

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: 773
Joined: Sat May 16, 2015 2:53 pm
Been thanked: 1 time
Contact:

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: 3120
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

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
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
User avatar
Torsten_Kelsch
Legend Bludit
Posts: 263
Joined: Thu Aug 27, 2015 10:24 pm
Location: Germany
Has thanked: 4 times
Been thanked: 2 times
Contact:

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: 3120
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

A solution is described here:

viewtopic.php?p=4630#p4630
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
User avatar
Torsten_Kelsch
Legend Bludit
Posts: 263
Joined: Thu Aug 27, 2015 10:24 pm
Location: Germany
Has thanked: 4 times
Been thanked: 2 times
Contact:

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
Legend Bludit
Posts: 263
Joined: Thu Aug 27, 2015 10:24 pm
Location: Germany
Has thanked: 4 times
Been thanked: 2 times
Contact:

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: 3120
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

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.
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
Post Reply