Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2009-05-19 19:59:17
- holygeez
- New Member
- Registered: 2009-05-14
- Posts: 7
if else article id #
I’m trying to get an image to appear depending on the article id # and then another article to appear depending on another article id # and then another image depending upon the section. However, if the article resides in the same section, then the article would have overriding status. How do I do this?
This is what I have;
<txp:if_article_id id="4">
<img src="image location" />
<txp:if_article_id id="2">
<img src="image location" />
<txp:if_section="sectionname">
<img src="imagelocation" />
<txp:if_else />
</txp:if_article_id>
Last edited by holygeez (2009-05-19 19:59:47)
Offline
#2 2009-05-19 20:39:49
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: if else article id #
<txp:if_section name="sectionname">
<txp:if_article_id id="4">
<img src="image location" />
<txp:else />
<txp:if_article_id id="2">
<img src="image location" />
<txp:else />
<img src="imagelocation" />
</txp:if_article_id>
</txp:if_article_id>
<txp:else />
<img src="imagelocation" />
</txp:if_section>
Remember to close every tag you open :)
This: <txp:if_else />
doesn’t exist.
EDIT: changed the code because I overlooked this:
However, if the article resides in the same section, then the article would have overriding status.
EDIT 2: sorry, forgot a line…
Last edited by els (2009-05-20 17:28:14)
Offline
#3 2009-05-20 01:30:56
- holygeez
- New Member
- Registered: 2009-05-14
- Posts: 7
Re: if else article id #
I saw you had <txp:if_section section=”“>. Shouldn’t it be, <txp:if_section name=”“> ? I looked at the tag wiki and there is no mention of a section attribute.
Last edited by holygeez (2009-05-20 01:31:29)
Offline
Re: if else article id #
Yes, you are right.
Offline
#5 2009-05-20 16:34:45
- holygeez
- New Member
- Registered: 2009-05-14
- Posts: 7
Re: if else article id #
Actually, there’s a slight issue with the above code. Those images for that specific articles will show up, however, any other articles within that section will be orphaned (ie; have no image appear). How can I have an image (ie; banner_lady) still show up for those other unnamed articles within that section? And btw, all other sections are having the banner_lady image appearing. Here is what I have;
<txp:if_section name="strategies">
<txp:if_article_id id="4">
<img src="/images/banner-certification.jpg" />
<txp:else />
<txp:if_article_id id="2">
<img src="/images/banner-coalition.jpg" />
</txp:if_article_id>
</txp:if_article_id>
<txp:else />
<img src="/images/banner_lady.jpg" />
</txp:if_section>
So then I tried the below (I simply put in the default name attribute). However, the banner_lady image shows up for EVERY article and section but those specific articles (4 and 2) mentioned below have no overriding power.
<txp:if_section name="default">
<txp:if_article_id id="4">
<img src="/images/banner-certification.jpg" />
<txp:else />
<txp:if_article_id id="2">
<img src="/images/banner-coalition.jpg" />
</txp:if_article_id>
</txp:if_article_id>
<txp:else />
<img src="/images/banner_lady.jpg" />
</txp:if_section>
Last edited by holygeez (2009-05-20 16:35:45)
Offline
#6 2009-05-20 17:38:35
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: if else article id #
holygeez wrote:
I saw you had <txp:if_section section=”“>. Shouldn’t it be, <txp:if_section name=”“> ?
Oh dear. Three edits needed to get it right… too much in a hurry when posting that code I’m afraid, my apologies!
Those images for that specific articles will show up, however, any other articles within that section will be orphaned (ie; have no image appear). How can I have an image (ie; banner_lady) still show up for those other unnamed articles within that section? And btw, all other sections are having the banner_lady image appearing.
OK, I think I misunderstood your question. So you don’t need an image for other sections than ‘strategies’? Then you can leave out the last <txp:else />
and the next line. Does this do what you want?
<txp:if_section name="strategies">
<txp:if_article_id id="4">
<img src="/images/banner-certification.jpg" />
<txp:else />
<txp:if_article_id id="2">
<img src="/images/banner-coalition.jpg" />
<txp:else />
<img src="/images/banner_lady.jpg" />
</txp:if_article_id>
</txp:if_article_id>
</txp:if_section>
Offline
#7 2009-05-20 18:05:07
- holygeez
- New Member
- Registered: 2009-05-14
- Posts: 7
Re: if else article id #
Oh no. I still need images for other sections. I’m simply using strategies to just simplify my question. That’s why I tried to use default as the name attribute in the second example hoping that the lady image will default for those articles that are not explicitly mentioned. I hope this helps. Thanks so much.
Offline
#8 2009-05-20 19:51:55
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: if else article id #
Well, I’m pretty sure that the code example in my previous post will display banner-certification.jpg for article #4, banner-coalition.jpg for article #2, and banner_lady.jpg for all other articles in section strategies. If it doesn’t, can you tell me what it does do and maybe post a tag trace of the page in question?
<txp:if_section name="default">
just means: if we are in section ‘default’ (which is actually no section at all, it’s the front page).
Offline
#9 2009-05-20 21:10:11
- holygeez
- New Member
- Registered: 2009-05-14
- Posts: 7
Re: if else article id #
Once I realized that i misread the default name attribute, then I was set. I just simply inputted all the section names in there and my problem was solved.
Offline
Pages: 1