Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Can custom tags be used with multiple images?
In the light of no real feature rich rating plugin for TXP, I was thinking of a work around using custom tags. Would it be possiblet o use custom tags in this way?
What I would do is create say 5 images representing stars (1-5 stars), upload these as 1.jpg, 2.jpg etc and in the custom tag mark it as rating. I would then insert the number corresponding to the rating. So if I place the number 3, it would output the image 3.jpg. Is this possible?
Thanks in advance
Offline
#2 2005-11-29 17:10:04
- Niconemo
- Member
- From: Rhône-Alpes, France
- Registered: 2005-04-18
- Posts: 557
Re: Can custom tags be used with multiple images?
Yes. Just do as you wrote then add this in your form :
<code>
<img src=“path_to_images/<txp:custom_field name=“Your custom field” />.jpg” />
</code>
You have to replace “path_to_images” and “Your custom field”, of course.
Last edited by Niconemo (2005-11-29 17:13:42)
Nico
Offline
Re: Can custom tags be used with multiple images?
ok sorry for being dumb but can you break that down for me? I’m excited that it’s possible but wonder if I might have explained it wrong? I would put that in a form, but I could only link one image correct? So I would have to use five custom fields for five different images? I was thinking it might be possible to assign one custom tag several images and allowing selection. So let’s say the above was done, and some new guy writes a document, wants to add a rating, does he have to enter all that code in the custom field, or could he just put a number in there and txp would select it?
Not sure if I’m explaining it right, but please let me know if I’ve confused myself :)
Offline
Re: Can custom tags be used with multiple images?
I think niconemo’s suggestion does just what you want.
Make 5 images as follows:
1.jpg – 1 star and 4 blanks
2.jpg – 2 stars and 3 blanks
…
5.jpg – 5 stars and no blanks
and upload them in whatever folder you want. Put this info where niconemo writes “path_to_images”, for example a folder called “sitegraphics”.
Make a custom field in txp called, for example “rating” and put the following code in your form or page source where you want the rating graphic to appear:
<code><img src=“sitegraphics/<txp:custom_field name=“rating” />.jpg” /></code>
In each article you wish to rate, enter a value between 1 and 5 in the custom field “rating” for that article (for the example above) and niconemo’s code will use the value given in that article and make an img link as follows:
<code><img src=“sitegraphics/3.jpg” /></code>
If you prefer, you could use categories for rating instead of a custom field. Then you could also list your articles according to rating (=according to category).
TXP Builders – finely-crafted code, design and txp
Offline
Re: Can custom tags be used with multiple images?
thanks to both of you, and for the explanation, it sounds promising. Cheers
EDIT: Ok I tried it, and here’s the code I used:
<code>
<div id=“rating”><strong>Rating:</strong><img src=”../images/<txp:custom_field name=“rating” />.png” /></div>
</code>
But there was no output. Is the code correct? I do have a custom tag called rating as well. The out put seems to be:
<code>
http://sekhu.net/txpattern/images/.png
</code>
With no number prefixed to the .png
Last edited by sekhu (2005-12-01 13:03:40)
Offline
#6 2005-12-01 15:39:51
- alexandra
- Member
- From: Cologne, Germany
- Registered: 2004-04-02
- Posts: 1,370
Re: Can custom tags be used with multiple images?
@sekhu
are you sure the path to images is correct?
Try: < img src=”/images/ …or… < img src=“images/== ..or.. < img src=“www.yoururl.com/images/
Last edited by alexandra (2005-12-01 15:42:13)
Offline
Re: Can custom tags be used with multiple images?
Do you actually have any numbers in the field anywhere?
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: Can custom tags be used with multiple images?
Well the numbers are on the images, the path to the images is correct. I have 5 images numbered 1-5.png
I don’t have the numbers in the code itself, as I was hoping entering the number in the rating field would output the rating image. I then found that it didn’t appear so used the WebDeveloper Extension for FF, and selected Find Broken Images, the result of which was the correct path but no images.
If this works, and if someone can figure out the problem, it might be worth writing up as it#s a much requested plugin that could be done simply with a little work and easier to customise.
Offline
Re: Can custom tags be used with multiple images?
Yes but I meant do you have any numbers entered into the field so that the tag can pick them up? I presume this is for articles.
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: Can custom tags be used with multiple images?
Well there;‘s a custom field called Rating, in that field I placed the number 1 as a test, which I thought would pick up the image
Offline
#11 2005-12-01 16:19:14
- alexandra
- Member
- From: Cologne, Germany
- Registered: 2004-04-02
- Posts: 1,370
Re: Can custom tags be used with multiple images?
you should debug this… see if you can adress 1.png without customfield at all
Offline
Re: Can custom tags be used with multiple images?
how do you mean alex?
something like:
<code>
<div id=“rating”><strong>Rating:</strong><img src=”../images/<txp:custom_field name=“rating” />1.png” /></div>
</code>
Not sure what you mean by debug. The images are there:
First Image
Second Image
Third Image
Fourth Image
Fifth Image
Ok I tried it without the custom tag and it displays.
Last edited by sekhu (2005-12-01 17:58:06)
Offline