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)


 * We still have this a little backwards. According to the Advanced Templates Help we can use parameters as template names. Please review the w:c:ChristianMusic:Template:Sandbox Song Index to see how this would work for your particular case.
 * To review: You will have a template for each album named Artist/Album. This template will be of the form


 * The Song Indexer template will call this template via: replacing the current CurrentTrack/NextTrack/PreviousTrack  and which will return the current/previous/next track name. You will need to include this call several times in the Song Indexer template, but that is a one off. Tjoneslo 19:07, 2 September 2006 (UTC)


 * Wow I never thought you could get arrays into wikitext, The closest thing I could come up with was string handleing(Though, I don't know if it's installed, I know parser functions, and Dynamic Function are, but I haven't tested strings) But since there is no looping that wouldn't work right. I'd half to look deeper into what you are doing to figure out what you are trying to do with the advanced funtions, but you guys seem to have a good handle on it already so I'll leave it to you. But I do have a small idea. I saw the Template Table extension when I was browsing the media wiki extensions section, and I haven't looked into what you have on the site currently, but the use of the TTable extension would allow you to create entire song lists, track lists, and a entire glossary all dynamicly updating using the templates that you are working on right now. dantman 13:56, 3 September 2006 (UTC)


 * As far as I can tell the string functions are not installed. But it may be because no one has asked. But yes, the template processing system in the Wiki is quite powerful. If you have an idea you would like to try out and don't mind me playing in your wiki, post a note either in the forumn or on my talk page. Tjoneslo 14:39, 3 September 2006 (UTC)