Unique changes for each theme

Want to share what MODs you've gotten to work with EM? Happy about all the time your're saving? Want to say "thanks"? Here's the place.
Forum rules
DO NOT give out any FTP passwords to anyone! There is no reason to do so! If you need help badly enough, create a temporary FTP account that is restricted to only the files that you need help with and give the information for that. Giving out FTP information can be very dangerous!
Locked
treblemaker
Registered User
Posts: 4
Joined: Thu Jul 28, 2005 10:01 am

Unique changes for each theme

Post by treblemaker »

I'm afraid I was unable to find help in the readme/faq/google (too many hits).
I prefer to use mod scripts to customize our forum rather than hand-edits so that I can reproduce the same changes more easily when we upgrade.

One such customization is to replace templates/*/images/phpBB_logo.gif with a different image for each theme that matches the color scheme of that theme.

However, Easymod -- for good reasons that I understand -- makes the same edits to all the themes so that all the themes end up having the same image. I have attempted to implement this using the following mod script:

Code: Select all

#
#-----[ COPY ]------------------------------------------
#
copy root/images/header_blue.jpg to templates/subTrail/images/header_blue.jpg

#
#-----[ COPY ]------------------------------------------
#
copy root/images/header_canvas.jpg to templates/subTrail/images/header_canvas.jpg
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/overall_header.tpl
#
#-----[ FIND ]------------------------------------------
#
<a href="{U_INDEX}"><img src="templates/subSilver/images/logo_phpBB.gif" border="0" alt="{L_INDEX}" vspace="1" /></a>
#
#-----[ IN-LINE FIND ]------------------------------------------
#
templates/subSilver/images/logo_phpBB.gif
#
#-----[ IN-LINE REPLACE WITH ]------------------------------------------
#
templates/subSilver/images/header_blue.jpg
#
#-----[ OPEN ]------------------------------------------
#
templates/subTrail/overall_header.tpl
#
#-----[ FIND ]------------------------------------------
#
<a href="{U_INDEX}"><img src="templates/subSilver/images/logo_phpBB.gif" border="0" alt="{L_INDEX}" vspace="1" /></a>
#
#-----[ IN-LINE FIND ]------------------------------------------
#
templates/subTrail/images/logo_phpBB.gif
#
#-----[ IN-LINE REPLACE WITH ]------------------------------------------
#
templates/subTrail/images/header_canvas.jpg
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
So, I guess my questions are several:
1) is it possible to write a mod script to override this default behaviour?
1) is there a different, better way to use easymod to accomplish this?
2) Does it even make sense to use easymod to do this?
3) Can someone point me to some reference docs that may address this type of question (unique changes per each theme)?

Thank you and Best Regards,

T.

Nightrider
Registered User
Posts: 7219
Joined: Tue Nov 16, 2004 8:54 pm
Location: Florida, US
Contact:

Re: Unique changes for each theme

Post by Nightrider »

Whenever subSilver is specified, then EM will attempt to modify all templates installed on your board. But if you change subSilver to an alternate template name in the OPEN command, then EM will ONLY modify the specified template. So if you want to add code that ONLY modifies a specific template, you can use the template name rather than subSilver and you should be good to go...

I have used EM to modify all 12 templates on my board and I've installed over 800 MODs into them. I wouldn't do it any other way...

Image

treblemaker
Registered User
Posts: 4
Joined: Thu Jul 28, 2005 10:01 am

Re: Unique changes for each theme

Post by treblemaker »

Nightrider,
Thanks for your reply.
But if you change subSilver to an alternate template name in the OPEN command, then EM will ONLY modify the specified template.
. What I'd like to do is have one change for subSilver and a different change for other templates. However, you 've got me thinking that maybe I can take advantage of the strongly ordered processing of the mod file to do something like:
change subsilver and (implicitly) other templates from a->b
later, change other templates explicitly from b->c
I suppose I also could do the other templates with a separate mod script.

Thanks for the suggestion. You helped me get un-stuck.
Best Regards,

T.

treblemaker
Registered User
Posts: 4
Joined: Thu Jul 28, 2005 10:01 am

Re: Unique changes for each theme

Post by treblemaker »

Hmm... that didn't work so well:

Code: Select all

#
#-----[ DIY INSTRUCTIONS ]------------------------------------------
#
Run this only after header_images_subSilver.mod has been applied
#
#-----[ COPY ]------------------------------------------
#
copy root/templates/subTrail/images/header_canvas.jpg to templates/subTrail/images/header_canvas.jpg
#
#-----[ OPEN ]------------------------------------------
#
templates/subTrail/overall_header.tpl
#
#-----[ FIND ]------------------------------------------
#
<a href="{U_INDEX}"><img src="templates/subSilver/images/header_blue.jpg" border="0" alt="{L_INDEX}" vspace="1" /></a>
#
#-----[ IN-LINE FIND ]------------------------------------------
#
templates/subSilver/images/header_blue.jpg
#
#-----[ IN-LINE REPLACE WITH ]------------------------------------------
#
templates/subTrail/images/header_canvas.jpg
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
Checked and double checked that the FIND strings are found, but still get
  • CRITICAL ERROR: Could not modify [templates/subTrail/overall_header.tpl]
Does easymod reject a template mod if it's not explicitly for subSilver? (subSilver is present and installed, though.)

Thanks and Best Regards,

bluenose
Registered User
Posts: 9
Joined: Thu Dec 28, 2006 4:58 pm

Re: Unique changes for each theme

Post by bluenose »

Thanks from me aswell.. That makes things a little more clear..

So you have 3 themes ..EasyMod will attempt to Install the mod on all three ?

What about if if it completes the install on two themes and one theme doesn't work ?

treblemaker
Registered User
Posts: 4
Joined: Thu Jul 28, 2005 10:01 am

Re: Unique changes for each theme

Post by treblemaker »

If I specify a mod for a subSilver template file, then Easymod successfully completes the mod for all installed themes.

The problem occurs because I want to do a different mod for each theme. For example, in this case I have a different header image for each theme. In this example it's trivial to edit the templates by hand but I prefer to not make hand edits if at all possible (and prefer to not have multiple custom images called "phpBB_logo.gif" even if they are in different directories)

If I specify a mod explicitly for a theme other than subSilver, easymod appears to be rejecting the mod, or maybe failing in some way (I understand what I am doing is quite probably outside the scope of easymod's intent so, no blame, just speculation).

For now I am content to make the hand edits, so this is more of an academic exercise: how to make Easymod do a different edit for each theme?

Thanks and Best Regards,

Nightrider
Registered User
Posts: 7219
Joined: Tue Nov 16, 2004 8:54 pm
Location: Florida, US
Contact:

Re: Unique changes for each theme

Post by Nightrider »

treblemaker wrote: Hmm... that didn't work so well:

Code: Select all

#
#-----[ OPEN ]------------------------------------------
#
templates/subTrail/overall_header.tpl
Checked and double checked that the FIND strings are found, but still get
  • CRITICAL ERROR: Could not modify [templates/subTrail/overall_header.tpl]

    Does easymod reject a template mod if it's not explicitly for subSilver? (subSilver is present and installed, though.)

No, EM will not reject any template unless:
  1. there is a problem with one of it's files, such as the file is missing or corrupt, or if the file permissions are set incorrectly,
  2. the font case of the template name is wrong,
  3. the template name is spelled incorrectly,
  4. the template is not installed in the ACP Styles Admin.
  5. the code in a FIND or IN-LINE FIND command cannot be found in the template file
So check to make sure the template name is subTrail, not subtrail, SubTrail, or any other font case combination. Make sure subTrail is installed in your ACP Styles Admin and make sure that the subTrail overall_header.tpl file exists. Make sure the file permissions are set correctly as well...

So is there more to this error message than what you posted? I can't tell if a FIND statement failed or whether EM couldn't find the subTrail overall_header.tpl from the OPEN command from the error message you listed above...
treblemaker wrote: The problem occurs because I want to do a different mod for each theme. For example, in this case I have a different header image for each theme. In this example it's trivial to edit the templates by hand but I prefer to not make hand edits if at all possible (and prefer to not have multiple custom images called "phpBB_logo.gif" even if they are in different directories)

If you want to add different MODs to some templates than you do to others, there are ways to workaround the issue. If you only want to add code to your subSilver template and none of the others, you can temporarily delete the alternative templates in your ACP Styles Admin then install the MOD into subSilver only. Then you can reinstall the alternate templates, and install any MODs that you ONLY want to add to your alternate templates by changing subSilver to your alternate template name in the MOD Script OPEN commands...

If you want to install the same MODs into all of your templates but the code would be different for each template, you would want to create Template Only versions of the MODs that you can use for each alternate template. Template Only versions of the MOD are particularly helpful when attempting to bring a template designed for an older phpBB version up to speed with the phpBB version of your board. Here is how you create Template Only versions of the MODs and phpBB Updates...

Creating Template Only MODs

All you need to do is create Template Only versions of the MODs that you have installed.
  1. First create a duplicate of the MOD script in a new text file. To make it easier to remember, just use the same MOD filename that the MOD author used, but add _template_only to the name. So if you are using the TopicCalender.txt file, the new Template only version would be named TopicCalender_template_only.txt.
  2. Then save the new Template Only MOD and store it in it's own separate templates only folder...
  3. If there are any files included with the MOD that are supposed to be uploaded to template folders, store them in the new Template only MOD folder maintaining the same folder structure that the original MOD used...
  4. Next add the name of the new Template to the end of the MOD Title using your favorite Text editor. So the MOD Title could look something like this if Aeolus is your new template name:

    Code: Select all

    ## MOD Title:  Topic calendar - Part 1 (common to all setup) Aoelus
    EM will recognize this as a new MOD if the MOD Title is different from what it has previously installed...
  5. Next strip out all NON-Template related modifications. All you want in this new Template Only version of the MOD are alterations for template files only. If there are any copy commands, only keep those that copy included files into template folders too..
  6. Then rename all instances of subSilver with your new Template name using the Replace All function that you can find in most text editors.
  7. Now you can upload the new Template Only MOD folder to the admin/mods and run it like you would any other MOD using EM.
[/list]

If you have added more than one new template, you would want to repeat Steps 6 & 7 for each Template except instead of using subSilver, you would use the name of the last template that you installed using this Template Only version of the MOD. So if the last template you modified with this was Aeolus and you want to apply the changes to Helius next, do a Replace All on Aoelus to Helius...

It really isn't that difficult to update each new template after the fact...

Image

Nightrider
Registered User
Posts: 7219
Joined: Tue Nov 16, 2004 8:54 pm
Location: Florida, US
Contact:

Re: Unique changes for each theme

Post by Nightrider »

bluenose wrote: So you have 3 themes ..EasyMod will attempt to Install the mod on all three ?

Yes, as long as subSilver is specified in the MOD's OPEN commands. EM will also attempt to modify all languages that you support whenever lang_english is specified...
bluenose wrote: What about if if it completes the install on two themes and one theme doesn't work ?

EM will always tell you if there are conflicts between the MOD script and alternative templates with Warning errors. At that point, EM allows you to go back and correct the MOD script or it will allow you to continue with the MOD install. So if you choose to ignore the Warning errors and complate the MOD install, you will have to manually add the code to the template files that were skipped...

Most template conflicts can be corrected by minimizing the FIND commands text though. EM ONLY needs to match a unique word or phrase to know where to move the file pointer into the phpBB file. So the entire line of code does not have to be in the FIND statement for EM to know where to go. Since alternative templates by their very nature are different than subSilver, then less is best in the FIND statements to minimize the chance of a conflict. For instance, EM will be able to find the correct line in the code better on the second instance of the following FIND statments:

Bad: guaranteed to fail more than it succeeds:

Code: Select all

#
#--------------[ FIND ]-------------
#
   <tr>
     <td class="row1"><span class="gen">{L_USER_ADR_BAN}</span></td>
     <td class="row2">
      <input type="radio" name="user_adr_ban" value="1" {ADR_BAN_YES} />
      <span class="gen">{L_YES}</span>&nbsp;&nbsp;
      <input type="radio" name="user_adr_ban" value="0" {ADR_BAN_NO} />
      <span class="gen">{L_NO}</span></td>
   </tr>
Good: this has a much better chance of succeeding...

Code: Select all

#
#--------------[ FIND ]-------------
#
<tr>
{L_USER_ADR_BAN}
<td
{ADR_BAN_YES}
<span
{ADR_BAN_NO}
<span
</tr>
Note that on multi-line FINDs, EM ONLY needs a unique word or phrase for each line for it to know whether it is a match or not. So as long as the code in the template has a <tr> on the first line, {L_USER_ADR_BAN} on the next, <td on the third, etc and there are no instances that do not match, then EM can find this code and act accordingly. So as you should be able to see that the second example is much more likely to succeed on more alternate templates where only one extra or missing character can prevent a match. For the first example, the class types can be different for each template, preventing EM from finding an EXACT match with the longer FIND commands...

Image

Locked