Jump to content

Dynamic blocks with parameters


Recommended Posts

I have an idea to show all types of content in Community about the subject on a single page. I have a database page in Pages about a subject. And there, right on this page I want to show feeds from other areas of the community about this subject: topic feed from forums, entries feed from blogs, images feed from gallery, event feed from calendar. It is possible to select all the content using tags. That's fine. But how to add all these feeds to the page?

I can create and setup custom plugin block for each page for each type of content. For "Subject A" I can create custom plugin topic feed, set it up to show topics with "Subject A" tag, custom plugin entries feed, set it up to show topics with "Subject A" tag and so on. For "Subject B" I can create custom plugin topic feed, set it up to show topics with "Subject B" tag and so on, and so on.

But this is insane. Is there another better way to do this? Maybe call a block with parameters or somehow call a feed plugin with parameters?

Link to comment
Share on other sites

5 hours ago, KVentz said:

Maybe it is possible to create a PHP block and call the widget with parameters via API or something? Get current page from URL, get tag field, call the widget with this tag... Is it possible? Are there any examples of PHP blocks?

Take a look at the similar content block, where the content is depending on the viewed item 😉

Link to comment
Share on other sites

  • 2 weeks later...
On 11/18/2021 at 8:42 AM, Darth Vortex said:

Why so complicated? Simply drag and drop them on one page.

There will be the same content on every page in the database. With Pages Sidebar I can add different content blocks per category but not per page.

On 11/18/2021 at 10:08 AM, Daniel F said:

Take a look at the similar content block, where the content is depending on the viewed item 😉

Do you mean this one? OK, that's fine, but this is only half of the solution:

// Using a PHP variable to store an array of pages => page names that we'll loop over
{{$myPages = array('help/apple' => "Apple", 'help/banana' => "Banana", 'help/orange' => "Orange");}}

<ul class='ipsList_inline cMyMenu'>
	{{foreach $myPages as $url => $title}}
  		// HOW TO CALL A PLUGIN WITH PARANETER HERE?
  		// Topic Feed PLUGIN WITH $title AS 'With tags' PARAMETER?
  		// To show topics with 'Apple' tag on 'Apple' page and with 'Banana' tag on 'Banana' page
  	{{endforeach}}
</ul>

 

The question is how to show a list of all topics with 'Apple' tag on the 'Apple' page in the database and a list of all topics with 'Banana' tag on the 'Banana' page in the same category?

 

Now I do this:

// Using a PHP variable to store an array of pages => page names that we'll loop over
{{$myPages = array('help/apple' => "Apple", 'help/banana' => "Banana", 'help/orange' => "Orange");}}

<ul class='ipsList_inline cMyMenu'>
	{{foreach $myPages as $url => $title}}
  		{{$topics_feed = 'custom_block_topics_feed_' . $title;}}
	    {block="$topics_feed"}
  	{{endforeach}}
</ul>

And I must create different blocks: custom_block_topics_feed_Apple with 'With tags — Apple' option, custom_block_topics_feed_Banana with 'With tags — Banana' option, custom_block_topics_feed_Ogange with 'With tags — Ogange' option.

Is there any better way?

Edited by KVentz
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Upcoming Events

    No upcoming events found
×
×
  • Create New...