Topic on User talk:Ritsu

From Elwiki
G123u (talkcontribs)

Yahoo it is me again. _(•̀ω•́ 」∠)_ ₎₎
I wanted to ask, would you happen to know if it's possible to add file redirects in templates? In particular, with the IBModel/IMModel templates, I'm wondering if something like, "If the file link exists, link to said file. If it doesn't exist, redirect to File:IBUnknown.png / File:IMUnknown.png" can be done?

Ritsu (talkcontribs)

Try using {{#ifexist:File:pagename|exists|does not exist}}

G123u (talkcontribs)

I... apologize, I seem to be having some difficulty getting this to work. If/When you have some free time, could I ask you to look over Template:ModelTest and let me know where I went wrong? >)-o

Ritsu (talkcontribs)

Can you provide an example of how you call it when it doesn't work?

G123u (talkcontribs)

Of... How I call it...? @@

Are you referring to calling the template via the {{ }} brackets? If so, it would be:

{{ModelTest

|IM=SWATBHat

|Lithia=yes

}}

...which should pull up File:SWATBHatLi.png. However, it either pulls up File:IMUnknown.png or a nonexistent link.

Ritsu (talkcontribs)

I see it now, you're checking if the page "SWATBHat" exists (since you only provided {{{IM|}}}), and not File:SWATBHatLi.png.

Maybe store it in a variable so that you can reuse it for both the condition of #ifexist and the outcome.

G123u (talkcontribs)

ooo... Thank you for your time, chief! Alas, I think this may be a bit beyond my current skill level. I will set this aside until I have a better understanding of wiki code. _(:3/

Ritsu (talkcontribs)

It's really easy though. I made an edit that should fix this.

G123u (talkcontribs)

O.
T-Thank you! |. v.)
I'm going to fiddle around with it a bit more before I copy it over to Template:IMModel.