Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2005-09-07 10:09:44
- lee
- Member
- From: Normandy, France
- Registered: 2004-06-17
- Posts: 831
Some code help please
Can anyone please tell me the right way to write the code below so that $category takes on the value of the current article url title, which I’m assuning is in $url_title. By current article url title I mean the “URL-only title” as displayed in Advanced Options in the Write tag.
Thank you.
<code>if(!$category){ $category = $thisarticle[$url_title]; }</code>
Offline
#2 2005-09-08 00:58:41
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Some code help please
Is this for when you’re creating/editing an article?
Offline
Re: Some code help please
I think what you want to do is something like: $category = $category ? $category : $thisarticle['url_title'];
If $category is set, then use its value, otherwise look up url_title in the thisarticle array. You look it up using quotes around the name of the field. This is all off the top of my head mind you.
Offline
#4 2005-09-08 07:55:35
- lee
- Member
- From: Normandy, France
- Registered: 2004-06-17
- Posts: 831
Re: Some code help please
Thanks both for helping me out, the code was perfect.
I used it in cno_gallery02 (see his example). The new code lets me create an image category with the same name as the URL-only title (from Article/Advanced Options) and the images in the category then appear in the article. This makes it nice and easy for clients to add mutiple gallery style images to articles.
Offline
Pages: 1