Author Topic: What's the right way to use maxvalues in a template?  (Read 9721 times)

0 Members and 1 Guest are viewing this topic.

Offline daddydave

  • Member
  • *
  • Posts: 28
    • View Profile
    • Me on Google+
What's the right way to use maxvalues in a template?
« on: August 27, 2010, 06:40:33 pm »
I'm starting to piddle around a little with templates. I am trying to get a template to display only the first 3 actors for the movie but it is displaying the whole list. I must have something wrong.
Code: [Select]
{%value=actors maxvalues="3"}
The whole line for that is:
Code: [Select]
<p><strong>(IMDB Rating:{%value=imdbrating}) Actors: {%value=actors maxvalues="3"}  Director: {%value=directors maxvalues="1"}</strong> {%value=description} </p>

Offline nostra

  • Administrator
  • *****
  • Posts: 2852
    • View Profile
    • Personal Video Database
Re: What's the right way to use maxvalues in a template?
« Reply #1 on: August 30, 2010, 11:09:50 pm »
You need to create a separate template file for the values and then use the following syntax in main template:
Code: [Select]
{%value=actors template="pages\actor.ptm" maxvalues="3"}
Gentlemen, you can’t fight in here! This is the War Room!

Offline daddydave

  • Member
  • *
  • Posts: 28
    • View Profile
    • Me on Google+
Re: What's the right way to use maxvalues in a template?
« Reply #2 on: August 31, 2010, 10:21:38 am »
Thanks, nostra!

Offline daddydave

  • Member
  • *
  • Posts: 28
    • View Profile
    • Me on Google+
Re: What's the right way to use maxvalues in a template? {%value}
« Reply #3 on: September 01, 2010, 09:31:45 pm »
One other thing, I was going to try to figure out this on my own using the existing templates as examples, but I am quite stumped.

I got it to work just as you said above using a subtemplate if the subtemplate contains only {%value} but this smashes the list of actor names up together without spaces. And if I do so much as put a comma to the right, I end up seeing the actual code {%value} in the output (along with the comma). I tried putting in some things in the main template as well, but without really understanding. So my new question is: is there an easy way to make it show commas in between the names?

Thanks again for all advice.

BTW I have noticed for a while that I have some of the ptm files from Plugins\Templates folder duplicated in Plugins folder itself. Is this normal or did I screw something up downloading extra templates from the forum into the wrong folder?
« Last Edit: September 01, 2010, 09:35:26 pm by daddydave »

Offline rick.ca

  • Global Moderator
  • *****
  • Posts: 3241
  • "I'm willing to shoot you!"
    • View Profile
Re: What's the right way to use maxvalues in a template?
« Reply #4 on: September 01, 2010, 09:43:40 pm »
Quote
BTW I have noticed for a while that I have some of the ptm files from Plugins\Templates folder duplicated in Plugins folder itself. Is this normal or did I screw something up downloading extra templates from the forum into the wrong folder?

I noticed the same thing recently, and wondered how I managed to do that. I wonder if the automatic updater put them there.

Offline daddydave

  • Member
  • *
  • Posts: 28
    • View Profile
    • Me on Google+
Re: What's the right way to use maxvalues in a template?
« Reply #5 on: September 03, 2010, 09:27:59 pm »

In the main template, I have
{%value=actors  maxvalues="3" template="ddlist\actor.ptm"}

In the subtemplate, I have
{%param=name}

This results in me seeing output to the effect of:
Quote
<strong>(IMDB Rating:6.3) Actors: {%param=name}{%param=name}{%param=name}  Director: Robby Grewal</strong>

If I change the subtemplate to {%value}, it displays the actors names instead of the {%param=name} code but I am not sure how to get commas in there because the built-in templates seem to have no problems displaying commas in between the actors and I can't figure out how they do it.

Offline nostra

  • Administrator
  • *****
  • Posts: 2852
    • View Profile
    • Personal Video Database
Re: What's the right way to use maxvalues in a template?
« Reply #6 on: September 03, 2010, 10:56:39 pm »
Adding a comma after {%value} should, actually do the trick.

If you use {%param=name}, then you need to call the field in the main templates with
Code: [Select]
params="full"
Gentlemen, you can’t fight in here! This is the War Room!

Offline daddydave

  • Member
  • *
  • Posts: 28
    • View Profile
    • Me on Google+
Re: What's the right way to use maxvalues in a template?
« Reply #7 on: September 04, 2010, 12:42:13 pm »
Perfect, I was going to ask you if there was anyway to get rid of the last comma without having to use Javascript, but then I decided to use &middot; instead of a comma, so it doesn't matter. Thanks again, Nostra.

« Last Edit: September 04, 2010, 12:44:44 pm by daddydave »

 

anything