- Posts: 13
COMMUNITY FORUM
Show star rating in extra fields...
- Jonas Aabye Olsen
-
Topic Author
- Offline
- New Member
Less
More
12 years 3 months ago #109918
by Jonas Aabye Olsen
Show star rating in extra fields... was created by Jonas Aabye Olsen
If i want to show a star rating depending on a value in the extra fields... Can this be done?
Extra field
- Rating : Value 0 - 10
So basicly i want to show between 0 and 10 stars depending on the value of that field...
I havent been able to find any metod, so...
I know the temple does a loop for every "extra field"
Can I do something like this :
IF Extra_field_navn = "rating"
for i = 0 to 10 {
if i < Extra_field_value
echo "<img FULL STAR>"
else
echo "<img Empty STAR>"
}
Do you know what I mean here?
Right now my template looks like this:
<span class="itemExtraFieldsLabel">
<?php
echo $extraField->name;
echo ": ";
echo $extraField->value;
?>
So - I dont want that to written out when the name is "rating", and the value is between 0 and 10
Extra field
- Rating : Value 0 - 10
So basicly i want to show between 0 and 10 stars depending on the value of that field...
I havent been able to find any metod, so...
I know the temple does a loop for every "extra field"
Can I do something like this :
IF Extra_field_navn = "rating"
for i = 0 to 10 {
if i < Extra_field_value
echo "<img FULL STAR>"
else
echo "<img Empty STAR>"
}
Do you know what I mean here?
Right now my template looks like this:
<span class="itemExtraFieldsLabel">
<?php
echo $extraField->name;
echo ": ";
echo $extraField->value;
?>
So - I dont want that to written out when the name is "rating", and the value is between 0 and 10
Please Log in or Create an account to join the conversation.
- jean-philippe
-
- Offline
- Premium Member
- [email protected]
12 years 3 months ago - 12 years 3 months ago #109919
by jean-philippe
Replied by jean-philippe on topic Re: Show star rating in extra fields...
Hi Jonas,
to get the extrafields you need to do this:
to get the extrafields you need to do this:
Emond, Jean-Philippe
Please Log in or Create an account to join the conversation.
- Astrid Pedersen
-
- Offline
- New Member
10 years 9 months ago #109920
by Astrid Pedersen
Replied by Astrid Pedersen on topic Re: Show star rating in extra fields...
Hi,
I have been struggling with this for a while.
I want my client to be able to assign 1-6 stars through the extra fields in the backend. He is a music journalist. The result should look somehting like this:
steffenjungersen.dk/volbeat-gaesteanmeldelse-refshaleoen
Right now it looks like this - the rating ("Karakter", at the bottom, only displays a number):
steffenjungersen.anansi.dk/test-anmeldelse-nummer-2
I tried to add your solution above to the item.php file. I added this (and the css code to k2.css):
<!-- Item rating -->
<?php if(isset($this->item->extra_fields[rating]) && ($this->item->extra_fields[rating] >= 0 || $this->item->extra_fields[rating] <=10)): ?>
<span class="starsbox stars<?php echo $this->item->extra_fields[rating]; ?>"></span>
<?php endif; ?>
I also made sure in the backend, that the alisa for "Karakter" is "rating".
Absolutely nothing has changed.
Please halp :-)
Best, Aztrid
I have been struggling with this for a while.
I want my client to be able to assign 1-6 stars through the extra fields in the backend. He is a music journalist. The result should look somehting like this:
steffenjungersen.dk/volbeat-gaesteanmeldelse-refshaleoen
Right now it looks like this - the rating ("Karakter", at the bottom, only displays a number):
steffenjungersen.anansi.dk/test-anmeldelse-nummer-2
I tried to add your solution above to the item.php file. I added this (and the css code to k2.css):
<!-- Item rating -->
<?php if(isset($this->item->extra_fields[rating]) && ($this->item->extra_fields[rating] >= 0 || $this->item->extra_fields[rating] <=10)): ?>
<span class="starsbox stars<?php echo $this->item->extra_fields[rating]; ?>"></span>
<?php endif; ?>
I also made sure in the backend, that the alisa for "Karakter" is "rating".
Absolutely nothing has changed.
Please halp :-)
Best, Aztrid
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
10 years 9 months ago #109921
by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Show star rating in extra fields...
You should look for a css solution.
Have the value of the extrafield echo as a css class on a div or span element and depending on that class use a diferrent background image(s).
Have the value of the extrafield echo as a css class on a div or span element and depending on that class use a diferrent background image(s).
Please Log in or Create an account to join the conversation.
- Astrid Pedersen
-
- Offline
- New Member
10 years 9 months ago #109922
by Astrid Pedersen
Replied by Astrid Pedersen on topic Re: Show star rating in extra fields...
Hi and thank you for your quick reply.
I think my problem is that I can't make the extra field echo an image as described above.
As you can see at the bottom of the article at steffenjungersen.anansi.dk/koncertanmeldelser/test-anmeldelse-nummer-2, it still echos the numeric value from the drop down.
Is it because I should use a different type of extra field?
I would love to be able to implement something like the built-in rating system with the graphic stars, but only to be used by my client, not the site visitors, but I can't seem to be allowed to limit the rating to registered/admins only.
Best, Astrid
I think my problem is that I can't make the extra field echo an image as described above.
As you can see at the bottom of the article at steffenjungersen.anansi.dk/koncertanmeldelser/test-anmeldelse-nummer-2, it still echos the numeric value from the drop down.
Is it because I should use a different type of extra field?
I would love to be able to implement something like the built-in rating system with the graphic stars, but only to be used by my client, not the site visitors, but I can't seem to be allowed to limit the rating to registered/admins only.
Best, Astrid
Please Log in or Create an account to join the conversation.