Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2008-09-08 09:09:04
- johnny5
- New Member
- Registered: 2008-09-08
- Posts: 8
Related articles ( that show only really related articles )
Hi,
There’s the related_articles tag and i also found a plugin (that judging by the comments of the users was buggy / obsolete?) that changed it’s way of working… But is there any
good way of showing only really related articles.
What i’m after is being able to choose in a simple way how the articles are related.
Example:
(article)
Topic: Blues Brothers
Text: This will be a review of the said movie. lorem ipsum ad nauseum
Related articles: Blues Brothers 2000, Ghostbusters (The relativiness based on both having the same actor)
I know i could get the information from the category but that could show any other review instead of the really relevant ones.
I was thinking that maybe this could be achieved by custom fields or something like that? Or am i asking a bit too much? :)
Offline
#2 2008-09-08 09:39:31
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: Related articles ( that show only really related articles )
johnny5 wrote:
I was thinking that maybe this could be achieved by custom fields or something like that? Or am i asking a bit too much? :)
Yes, it can be achieved by using custom fields for actors and then <txp:article_custom custom /> to output the list.
Untill txp 4.07 is out you have to use the plugin asy_wondertag to nest tags in tags.
So, install asy_wondertag, create a custom field (e.g. “actors”) and then:
bc. <txp:asy_wondertag>
<txp:article custom actors=”<txp:custom_field name =“actors” />” />
</txp:asy_wondertag>.
But if you need (as I think) to associate more than one actor for movie you can use keywords instead of a custom_field (or you have to install glz_custom_fields – which is not free)
Offline
#3 2008-09-08 11:08:42
- johnny5
- New Member
- Registered: 2008-09-08
- Posts: 8
Re: Related articles ( that show only really related articles )
Thank you for your reply!
I got somewhere with your suggestions but i guess i didn’t understand the whole idea or i maybe thinking it in a wrong way. I’m still just getting to grips with the whole Textpattern so i’m probably messing up more with the tags rather than doing anything useful ;)
Here’s what i did:
- made the custom field named actors
- added two reviews that both contained the same actor name in the custom field ( i might be missing some logic here? I was thinking that “tagging” them like this would tell the program that these two are really related).
- added the example code you gave me (in the layout so that the review is shown in the middle of the page and the related articles are shown in the right sidebar)
What happens is that when i open either of the reviews it shows the review like it’s supposed to and in the right sidebar it shows the exact same review (in full) again. I’d prefer to show the headers (in this case movie names) as links to the full reviews.
But messing around with these tags isn’t exactly a bad thing. At least i managed to get it to show something and all the trial & error should help me to learn more about Textpattern.
Also you’re right that using just one name would be oversimplifying the whole idea. But i could use the idea in other ways (even in the simple form) so i’m still interested in getting it together.
Offline
#4 2008-09-08 11:51:06
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: Related articles ( that show only really related articles )
Ok, first of all keep in mind that with txp you can achieve the same result in different ways so first read this to know all possible attributes for a tag.
In your case I think the best option is this:
1) put your comma separated list of actors in the “keyword” field in the “write” tab for every new article (movie);
2) use this code for related articles:
<ul>
<txp:asy_wondertag>
<txp:article_custom keywords=”<txp:keywords />" form="your_related_articles_form" />
</txp:asy_wondertag>
</ul>
3) in the “forms” tab create a new form named “your_related_articles_form” (or whatever you want) like this:
<li><txp:permlink><txp:title /></txp:permlink></li>
This should work, sorry but I’m in a hurry so I can’t elaborate now
Last edited by redbot (2008-09-09 12:52:29)
Offline
#5 2008-09-09 11:23:30
- johnny5
- New Member
- Registered: 2008-09-08
- Posts: 8
Re: Related articles ( that show only really related articles )
Thanks for your reply!
>This should work, sorry but I’m in a hurry so I can’t elaborate now
No worries. Any comment is a bonus and your code examples have helped me to further my knowledge of the Textpattern. But believe it or not … I’m still struggling with this :)
I’m probably doing something wrong here so i didn’t want to post immediately and whine about it. Instead i made a new demo site where to test the code and see if the problems were related to the sections etc. or something else i was doing with the other (demo) site.
But even with the new demo site i had the same problems. So here goes:
- added the example code you gave to the page template
- made a new form with the example form code information (as referenced in the page template code)
- added a few posts that had keywords
The outcome was the same as before. When i check the page it shows the topic (link) to the same page i’m looking at. So if it were a Blues Brothers page it says “Blues Brothers” and nothing else (instead of showing any other pages that contain the correct keywords).
I kept on struggling with this and tried everything i could think of … until today i noticed that there was an error message. I didn’t notice it yesterday because it was obscured by the background color. It says “tag_error <txp:keywords/> -> Textpattern Notice” and gives information that the tag can’t be used outside the article.
BUT i’m not 100 % sure anymore if i had that error message yesterday or not (just to make things more complicated). The bottom line is that the only thing i’ve managed to get it to show (this and previous code example based on custom field) was a link to the same page i was already looking at.
I also made sure that the wondertag plugin was correctly installed on both of the sites. And i’m running Textpattern version 4.0.6.
Your code examples are so clean and simple (yeah i noticed the small typing error tile / title and fixed that) that i would think that they’re correct and i’m doing something “funky” here. But i don’t really know what.
Thanks again!
Offline
#6 2008-09-09 12:59:54
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: Related articles ( that show only really related articles )
Ouch! yes my suggestions were quite unaccurate (I’ve corrected my typos). Can you please point me to your demo site (if it is a public site) or can you post here your page template code? Maybe I’m wrong but I still think my example code should work.
Last edited by redbot (2008-09-09 14:08:55)
Offline
#7 2008-09-09 18:17:54
- johnny5
- New Member
- Registered: 2008-09-08
- Posts: 8
Re: Related articles ( that show only really related articles )
Ok, i’ll post the template & form code i’m using tomorrow (i’m currently on a different computer).
Thanks!
Offline