Jump to content

Create a conditional feeds block


EricT

Recommended Posts

Posted

I want to show a feed block only for some forum categories.

So I created a new block : Type Plugin, and with a FEED
On the content block, I can choose "Use as a base for a custom template"

Then I see the code for the block.
At the top of the code I add a condition : for example one of them : 

But none are working :cry:

I have another idea to do that : create new blocks using feeds. Get the key of the block and add them in the HTML template with conditions (HTML logics)

It is working well, but there is some glitch in the design. I suppose I don't add the block in the right place

It is on sidebar HTML code (here without HTML logics added) : 

Quote

{{if isset(\IPS\Output::i()->sidebar['widgets']['sidebar']) and count( \IPS\Output::i()->sidebar['widgets']['sidebar'] ) and ( \IPS\core\Advertisement::loadByLocation( 'ad_sidebar' ) ) }}
            {advertisement="ad_sidebar"}
            <br><br>
        {{endif}}
        {block="annonces_romaines"}
        {template="widgetContainer" group="global" app="core" params="'sidebar', 'vertical'"}
    </div>
{{endif}}

Anyone could help me ? :)

 

Posted

I dont see your conditional statement that pertains to only showing the code in certain categories.

{{if request.app == 'forums' && request.module == 'forums' && request.id == 3}}Your Code{{endif}}
	

Posted
9 hours ago, EricT said:

It is on sidebar HTML code (here without HTML logics added) : 

Yes I didn't add HTML logics in the code example

If I add your conditional on the first solution (creating a new block with feed and "Use as a base for a custom template"), it will work ?

For the second solution (add the key in HTML Code), the problem is not about condition, but about the place where I have to put it in the HTML code.
 

If I do that : 

Quote

{{if isset(\IPS\Output::i()->sidebar['widgets']['sidebar']) and count( \IPS\Output::i()->sidebar['widgets']['sidebar'] ) and ( \IPS\core\Advertisement::loadByLocation( 'ad_sidebar' ) ) }}
            {advertisement="ad_sidebar"}
            <br><br>
        {{endif}}
        {block="annonces_romaines"}
        {template="widgetContainer" group="global" app="core" params="'sidebar', 'vertical'"}
    </div>
{{endif}}

There are some design problems

I would prefer solution 1 : using a custom block feed with conditions. But I can't make it work

Posted

Any ideas to do what I want ? :unsure:

It is a shame it is not possible easily to build targeted adverts, rss blocks, others blocks etc...
A forum usually has got different categories. It is better to show specifics advert or rss block for each categories.
For now, it is only possible to show a different ad or rss block for specifics site areas (topic, forum, calendar, etc...)
I would sponsor 150$ for a good app which manage this

Posted

It is built for adverts only. But I am going to test it for this.
My major need is about displaying rss feed depending of the forum category

I don't understand why this solution doesn't work : 

On 16/12/2016 at 9:14 AM, EricT said:

Capture d’écran 2016-12-16 à 09.11.08.png

Thank you

Posted
1 hour ago, EricT said:

My major need is about displaying rss feed depending of the forum category

Check part of condition

Start with {{if request.app == 'forums'}}

{{if request.app == 'forums'}}
    Test code
{{endif}}
1 hour ago, EricT said:

It is built for adverts only.

On your screenshot I see $adverts ;)

Posted
6 minutes ago, Nathan Explosion said:

So, to clarify, you are looking to display something depending on the category that a forum is in - correct?

Yes

6 minutes ago, Nathan Explosion said:

So you need to find out what the category of the forum is, instead of matching to request.id which is the id of the current forum?

This condition :

Quote

{{if request.app == 'forums' && request.module == 'forums' && request.id == 3}}Your Code{{endif}}

is to check if we are on forum app and id the forum id is 3. Then the code is shown
I tested with forum id = 35 which is one of my forum id. But nothing is shown when I add the block in the specific forum

I tested with only this condition : {{if request.id == 35}} and it is the same
I tested with a block inside sidebar and inside the forum index page

Two possibilities : 

- it is not possible to check the forum id in the block

- request.id is not the id of the forum

 

Just now, EricT said:

what the category of the forum is

If the url of the forum is site.com/forum/35-gauloises/, I suppose 35 is the id of the forum (== the category id)

Posted

Following is working fine for me:

{{if request.app == 'forums' && request.module == 'forums' && request.id == 6}}
BANANA!!!
{{else}}
SAUSAGE!!!
{{endif}}

6 = the ID of a category which contains 2 forums (ID 7 & 8)....if I'm in the category, where the forums are listed, then the display is BANANA!!! but if I go in to either of the forums (7 or 8) then it becomes SAUSAGE!!!

Taking the above example, are you attempting to have BANANA!!! display when viewing 6, 7 & 8 or just display in the category 6?

Note: at times, due to cache, I had to hard refresh the browser to get it to display the correct output.

Posted

I have difficulties to explain exactly what I mean with my poor english

I already use HTML logic on my community

- on HTML file

OR using

- "PHP & TXT Widget" Plugin

It is sometimes a bit annoying because everytime I add a forum category, I have to update in HTML
But it is working

But there is something I can't achieve :

Using HTML logic to display a RSS FEED block (in my case classifieds advert block but it could be any rss feed block)

I tried two solutions : 

1) Create a block based on RSS FEED, get the key of block and put it in HTML code with some HTML logic

--> this is working but there is some glitch in the design (images or text doesn't appear very well)
--> maybe I didn't insert it in the right place in HTML ?

2) Create a block based on RSS FEED and then on the content block, it is possible to choose "Use as a base for a custom template"

Then it is possible to add some HTML logic at the top of the block for example.

--> This is not working at all

 

I would really prefer the second solution and I don't know how it is not working

Posted

Yes, I always try a helloworld first

But as I said, I already use HTML logic in all my site and it is working fine

Now I only want to display a rss block with any HTML logic

I tried to display the RSS block without HTML logic : it works
I tried to display the RSS block with a small HTML logic (a HTML logic I already use in my site) : it doesn't work

I can't do smaller step :cry:

Example of HTML logic I am currently using in my site :

- For guest I am displaying in the sidebar a banner and a link to sign in : I use "PHP & TXT Widget" Plugin for this with HTML logic
- For guest I am displaying adsense ads and only in some forums : I use HTML logic in HTML file of my theme
- For all user, I am displaying banners from a partener : one banner for one forum category : I use "PHP & TXT Widget" Plugin for this with HTML logic

ALL are working, so I have a lot of example of HTML logics to use for my new need (RSS block)

17 minutes ago, EricT said:

1) Create a block based on RSS FEED, get the key of block and put it in HTML code with some HTML logic

--> this is working but there is some glitch in the design (images or text doesn't appear very well)
--> maybe I didn't insert it in the right place in HTML ?

HTML logic is working in this solution. But the design result is quite bad

Posted
7 hours ago, Nathan Explosion said:

Start small....get the logic working first, then add the content in. Separate things out so you know what is causing the problem if/when it presents itself.

I followed your advice : 

Create a block using RSS FEED and change the content with very simple code.

First try : 

test_cond.jpg

--> The test is {{ if request.app == 'forum' }}
--> I added the block in forum and in calendar : HelloWorld didn't show

Second try : 

test_cond2.jpg

--> The test is {{ if request.app != 'forum' }}
--> I added the block in forum and in calendar : HelloWorld is showing in both

So I think in this case (using Block with FEED), the variable request.app is not accessible (and all variables except RSS FEED variables)

Am I wrong ?

 

 

Posted
6 hours ago, Nathan Explosion said:

forums not forum 

Yes, if you look at screenshot, I put forums ;)

24 minutes ago, newbie LAC said:

Give someone acp access to debugging. Maybe you did something wrong.

Ok, I will send you a PM with admin account, thank you

Posted

Conclusion : 

Solution 1 using HTML Logic inside the RSS block is not the good solution because of the block RSS caching

Solution 2 using HTML templates + block key + HTML logic is working but the block insertion needs to be wraping.

Thank you to @newbie LAC for his help !

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...