Forum:How to do arrays in a template?

Please examing the template. I would like to simplify calling it. As is, I have to pass a lot of parameters each time. (Please see w:c:christianmusic:Andrew Peterson/Carried Along/Nothing To Say's source for an example. It is at the end of the page.)

It is a real pain to call and takes too long to write the call. I was thinking of having an intermediate template that would be only passed the equivilent of the existing CurrentTrack parameter. It would then pass elements of an array into the actual Song Indexer template.

Furthermore, I would like to build the links up rather than having the entire link passed in. Each link is in the form Artist/Album/SongName. Rather than pass the entire string for each link, why not build the link up from elements. Will that work? Suppose the array mentioned above contained only song names (no pipes). I could pass the album and artist names seperately. Will 06:52, 1 September 2006 (UTC)


 * If I interpret your question correctly, you want to know if you can pass tempates as paramters. Answer is yes. Second question, can you use index paramters to a template instead of named parmater to make them easier to write, also yes.


 * This is your current template


 * You need to create a new template: Song, with the following text:

// Track
 * You call this template as:


 * So a call to your Song Indexer template looks like:


 * If didn't interpret your question correctly, please let me know. Tjoneslo 14:30, 1 September 2006 (UTC)

--- You got part of it. However, I want to make what I put into each page look more like this:

That would then evaluate to what you had. Doable? Will 19:01, 1 September 2006 (UTC)


 * In theory. You would need to create a template for each album however, and a really messy one at that. If you really interested in seeing this done, let me know and I'll create a template one in your wiki. Tjoneslo 02:30, 2 September 2006 (UTC)

--- One template for each album is better than retyping complex calls for each track. My post earlier must not have made it in. I thought I had it posted. Sorry. Earlier today, I created   and  🇦🇱  to build track and album links respectively. I just found documentation on arrays. What I do not know is how to test the size of the array so the I can test if the current track is the last track. (In that case, I need to disable the Next link.) Will 03:03, 2 September 2006 (UTC)


 * Ok. I have a new version of Song Indexer that is not compatible with most existing uses.  It is below.  I am having troubles calling it from the album template that I mentioned.  The album template calls the array template, but then I would have to duplicate the array code (for a total of three tracks).  I want to list the current, previous, and next tracks for each song.  As is, I appear to need two templates for each album.  Did I miss something? Will 04:13, 2 September 2006 (UTC)

Update: I have updated all the song pages for the Andrew Peterson Carried Along album to use the simplified Song Indexer call. You will also find a second template call immediately after the Song Indexer call. That is what I want to end up with. Currently, however, it only evaluates the array. I am still looking into what is needed to have it call Song Indexer.


 * You are too fast for me. I think you have it figured. You need to add the calls to the Song Idexer template (10 in this case) to the Andrew Peterson/Carred Along template. Tjoneslo 04:43, 2 September 2006 (UTC)

---Actually, check out how the current versions of   and    work. The album template is the only one duplicated because it calls Song Indexer rather than, as you suggested just now, the other way around. However, I do not like having three copies of the array code in the album template. Any ideas on how to fix that? Will 04:52, 2 September 2006 (UTC)