Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-11-29 16:52:27

sekhu
Member
Registered: 2005-05-12
Posts: 428
Website

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

#3 2005-11-29 19:31:55

sekhu
Member
Registered: 2005-05-12
Posts: 428
Website

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

#4 2005-11-30 20:46:54

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,250
Website GitHub

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

#5 2005-12-01 10:35:17

sekhu
Member
Registered: 2005-05-12
Posts: 428
Website

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

#7 2005-12-01 15:46:09

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

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

#8 2005-12-01 15:57:27

sekhu
Member
Registered: 2005-05-12
Posts: 428
Website

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

#9 2005-12-01 16:05:20

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

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

#10 2005-12-01 16:12:56

sekhu
Member
Registered: 2005-05-12
Posts: 428
Website

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

#12 2005-12-01 17:55:40

sekhu
Member
Registered: 2005-05-12
Posts: 428
Website

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

#13 2005-12-01 18:30:32

Niconemo
Member
From: Rhône-Alpes, France
Registered: 2005-04-18
Posts: 557

Re: Can custom tags be used with multiple images?

It is a very basic thing and it should work… there must be a very little bug somewhere in your operations ;-)

Ok I tried it without the custom tag and it displays.

So it is not a path problem. OK

Then :

Are you sure the field is exactly “rating” (in your advanced preferences)

Are you sure there is a number between 1 and 5 entered in the field of the article you’re viewing ?

Are you sure there is a #rating{} selector in your CSS ?

What XHTML code is output exactly on this line ? (it isn’t possible to have a direct link I guess…)

Last edited by Niconemo (2005-12-01 18:44:53)


Nico

Offline

#14 2005-12-01 18:36:10

Niconemo
Member
From: Rhône-Alpes, France
Registered: 2005-04-18
Posts: 557

Re: Can custom tags be used with multiple images?

> sekhu wrote:
> something like:
> <code><div id=“rating”><strong>Rating:</strong><img src=”../images/<txp:custom_field name=“rating” />1.png” /></div></code>

Err… There is a problem there <txp:custom_field name="rating" />1.png in your code ! The “1” should not be there ! It will display 11.png, 21.png, etc. instead of 1.png, 2.png…

txp:custom_field will display exactly what is in you custom field : no more no less. It won’t do any operations. So <txp:custom_field name="rating" />.png will output “hello.png”, “10.png”, “How do you do ?.png” if there is “hello”, “10” or “How do you do ?” in the custom field.

Last edited by Niconemo (2005-12-01 18:43:52)


Nico

Offline

#15 2005-12-01 19:19:23

sekhu
Member
Registered: 2005-05-12
Posts: 428
Website

Re: Can custom tags be used with multiple images?

> Niconemo wrote:

> > sekhu wrote:
> something like:
> <code><div id=“rating”><strong>Rating:</strong><img src=”../images/<txp:custom_field name=“rating” />1.png” /></div></code>

Err… There is a problem there <txp:custom_field name="rating" />1.png in your code ! The “1” should not be there ! It will display 11.png, 21.png, etc. instead of 1.png, 2.png…

txp:custom_field will display exactly what is in you custom field : no more no less. It won’t do any operations. So <txp:custom_field name="rating" />.png will output “hello.png”, “10.png”, “How do you do ?.png” if there is “hello”, “10” or “How do you do ?” in the custom field.

No, I put that example in with regards to alex’s suggestion of troubleshooting. I have used the code without the 1 which displays a 1 rating in every entry, so again it’s not a path problem but something in the code which has either gone wrong, or perhaps it’s abug?

Basically it outputs nothing, the path it displays is as above but without selecting either the chosen number in the custom tag field (any number 1-5 for example), or anything else. FF displays it as a broken image, with no value preceeding the .png

EDIT: Ok it works it was a case issue, I had used Rating not rating and now it displays.

This is very excellent, now does anyone have plans to write this up? I noted a few people requesting a rating plugin and well this is the next best thing for me. Cheers everyone

Last edited by sekhu (2005-12-01 19:25:00)

Offline

Board footer

Powered by FluxBB