Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Central storage for site-wide constants: Helpful?
Bloke wrote:
Is this still related to your foreach thing? I couldn’t quite get my head round your problem. If I get a chance I’ll take another gander.
Well, I thought I’d let you off the hook rather than make you my personal code-slave. I’ve thought about it a lot, and I can’t see any way around the multiple similar forms and multiple article_custom calls. But I’ll give you a login if you wanna try…
Last edited by mrdale (2008-07-03 06:15:26)
Offline
#50 2008-07-03 14:59:05
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Central storage for site-wide constants: Helpful?
maniqui wrote:
So, I would rewrite it like this:
Hehe, that’s what I was trying to avoid :) Of course I realized (shortly after posting) that it won’t do at all what I wanted (replace chh_if_data). But I’m more interested if it will work at all (just to check if I’m ‘getting’ it). You are right that limit=5 is not much, so let’s make that 99.
This is what I hope it will do:
<txp:if_individual_article>
<h3>Related Articles</h3>
<txp:variable name="match" value='<txp:category1 />' />
This is setting the value of variable ‘match’ to category1 of the current individual article.
<txp:article_custom limit="99">
Calls all articles (well, 99 of them).
<txp:if_article_category name='<txp:variable name="match" />'>
checks for each article called with article_custom if it’s category equals the previously set value (= category1 of the current individual article). If so, display it, if not, display ‘Not related.’:
<p><txp:permlink><txp:title /></txp:permlink></p>
<txp:else />
<p>Not related.</p>
</txp:if_article_category>
</txp:article_custom>
</txp:if_individual_article>
So I expect to see 99 lines that are sometimes a permlink (if the category matches) and sometimes a line ‘not related’. But I’m not sure if the variable called within the article_custom form will keep it’s original value, or if it will be set to category1 of the article being fetched. In that case it won’t work at all.
Hmm… hope I made myself clear…
Offline
#51 2008-07-03 15:33:42
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,310
Re: Central storage for site-wide constants: Helpful?
You’ve set yourself an interesting goal! :)
The following is meant like placing a bet ;)
As far as I understand the variable value is taken from the individual article. You don’t use your article custom as opening/closing tag and but don’t have a variable tag in between these, so the variable value is only set once and therefore should remain the same.
Last edited by uli (2008-07-03 22:17:30)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: Central storage for site-wide constants: Helpful?
I was going to try and get this “variables” thing sorted in my head before I started confusing myself with combining it with the new “tags-within-tags” thing (which I do understand). So correct me if I’m wrong, but I thought that variables were set once only and you could have as many of them as you liked. These could probably be contained in their own form but you don’t want the form to be visible “on-screen” so it would be called to the <head></head> section of the page with the normal <txp:output_form form="variables" />
tag assuming you had called the form “variables”. Then you just call them into your code as required. Is that correct?
Last edited by thebombsite (2008-07-03 20:24:06)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: Central storage for site-wide constants: Helpful?
And further, assuming what I said above is correct, you could wrap the <txp:output_form />
tag with <txp:if_section>
tags or <txp:if_category>
tags calling different forms into the <head></head> for different site conditions??
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: Central storage for site-wide constants: Helpful?
Stuart – I’m still trying to wrap my head around it too, but from Wet’s example, I think you (using the tag in tag you didn’t want to get into), and conditionals, you can set and reset the variables dynamically.
Those who “get it” – is my understanding correct?
Offline
#55 2008-07-03 22:00:50
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Central storage for site-wide constants: Helpful?
maverick wrote:
Stuart – I’m still trying to wrap my head around it too, but from Wet’s example, I think you (using the tag in tag you didn’t want to get into), and conditionals, you can set and reset the variables dynamically.
Those who “get it” – is my understanding correct?
I still don’t feel that I really ‘get it’ ;) but that’s how I interpreted wet’s ‘even/odd’ example as well.
uli wrote:
You don’t use your article custom as opening/closing tag and don’t have a variable tag in between these
Now I don’t follow… do you mean I don’t (I just did, didn’t I?) or I can’t or shouldn’t? I used article_custom as a container tag mainly to shorten the code I needed to post for my example, but as soon as we can use variables we will also be able to use article and article_custom as container tags, don’t we? And I do have a variable tag inside (which of course also could have been in a form if I’d used <txp:article_custom form="blah" />
), I’m just not setting a value so I assume it will keep the value that was set before. But I’m still not sure if I’m right…
Offline
#56 2008-07-03 22:14:25
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,310
Re: Central storage for site-wide constants: Helpful?
Oh dear, today’s not my day, Els. Should have seen me in the Howdy forum this afternoon :/
What I meant is the sentence without the negative “don’t”, must be a remainder from re-writing my post.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: Central storage for site-wide constants: Helpful?
I think the only way to sort this out is to install a vanilla txp and just start coding to see what the hell works and what doesn’t. :)
How long have we got?
And this would be a prime case for opening up the “How to’s and examples” forum. Yes I know it was supposed to end up in the wiki but I don’t think we can wait that long quite frankly. No disrespect intended to the wiki developers.
Last edited by thebombsite (2008-07-03 22:26:18)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#58 2008-07-03 22:49:32
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,310
Re: Central storage for site-wide constants: Helpful?
thebombsite wrote:
So correct me if I’m wrong, but I thought that variables were set once only
I’d never correct you ;) At the moment I’m just presuming. I tried to find an evidence for my theory but admit I didn’t find one, yet. I’m rather sure, though, you can change variables values according to conditions met.
<txp:if_category name="people"><txp:variable name="menu_group" value="people" /></txp:if_category>
[ ... menu content based on «people» ... ]
and later
<txp:if_author name="photographer"><txp:variable name="menu_group" value="portrait" /></txp:if_author>
[ ... menu content based on «portrait» ... ]
and you could have as many of them as you liked.
By all means.
And yes, if you like, please set up a pre 4.0.7 and look what works and what doesn’t. I’m curious :)
Edit: I could have used tags in tags, but didn’t want to overheat my brain today ;)
Last edited by uli (2008-07-03 22:53:23)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: Central storage for site-wide constants: Helpful?
Els wrote:
I expect to see 99 lines that are sometimes a permlink (if the category matches) and sometimes a line ‘not related’.
I threw your example up for a quick test run on one of my sites where I have an svn copy of 4.0.7 and a number of articles. I don’t have much time to play around before I have to leave for the day, but what it returned was an alternating list of articles’ permalinks and not related.
as in:
- permalink
- not related
- permalink
- not related
- permalink
- not related
and so on.
Mike
Offline
#60 2008-07-03 23:01:13
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Central storage for site-wide constants: Helpful?
Alternating??? I guess that means I still don’t ‘get it’… I’m going to sleep on this and tomorrow I’m going to set up a test install to figure it out once and for all!
Offline