help modify template file for mod with install.xml

Started by Pipke, May 16, 2016, 05:44:05 AM

Previous topic - Next topic

Pipke

ive got this code in the install.xml file


<file name="$themedir/Recent.template.php">
<operation>
<search position="replace"><![CDATA[', $txt['started_by'], ' <strong>', $topic['first_post']['member']['link'], '</strong>]]></search>
<add><![CDATA[', $txt['started_by'], ' <strong>', $topic['first_post']['member']['link'], '</strong>';
if ($modSettings['abm_messageindex_showtime'])
echo ' ' ,$txt['on'], ' ' ,$topic['first_post']['time'];
echo']]></add>
</operation>
<operation>
<search position="replace"><![CDATA[<td class="subject ', $color_class2, ' windowbg2">]]></search>
<add><![CDATA[<td class="subject ', $color_class2, ' windowbg2">';
$abm_avatar_size = $modSettings['abm_avatar_size_message'] + 4;

if (($modSettings['abm_messageindex'] == 'first') || ($modSettings['abm_messageindex'] == 'both'))
{
if((empty($topic['first_post']['member']['avatar'])) || (abm_mod_checkurl($topic['first_post']['member']['avatar']) == 404))
echo'<div style="padding-left: ', $abm_avatar_size,'px; position: relative;">', $topic['first_post']['member']['id'] ? '<a href="' .$topic['first_post']['member']['href']. '">' : '', '<img class="abm_avatar_message" src="'.$settings['images_url']. '/abm_avatar.gif" alt="" />', $topic['first_post']['member']['id'] ? '</a>' : '';
else
echo'<div style="padding-left: ', $abm_avatar_size,'px; position: relative;"><a href="' ,$topic['first_post']['member']['href'], '">'. $topic['first_post']['member']['avatar'].'</a>';
}
echo']]></add>
</operation>
<operation>
<search position="replace"><![CDATA[<td class="', $color_class2, ' lastpost windowbg2">]]></search>
<add><![CDATA[<td class="', $color_class2, ' lastpost windowbg2">';
if (($modSettings['abm_messageindex'] == 'last') || ($modSettings['abm_messageindex'] == 'both'))
{
if((empty($topic['last_post']['member']['avatar'])) || (abm_mod_checkurl($topic['last_post']['member']['avatar']) == 404))
echo'<div style="padding-left: ', $abm_avatar_size,'px; position: relative;">', $topic['last_post']['member']['id'] ? '<a href="' .$topic['last_post']['member']['href']. '">' : '', '<img class="abm_avatar_message" src="'.$settings['images_url']. '/abm_avatar.gif" alt="" />', $topic['last_post']['member']['id'] ? '</a>' : '';
else
echo'<div style="padding-left: ', $abm_avatar_size,'px; position: relative;"><a href="' ,$topic['first_post']['member']['href'], '">'. $topic['last_post']['member']['avatar'].'</a>';
}
echo']]></add>
</operation>


However, this method has two problems. First of all the lines to search for (search position) are double on this template, i also want to do this modify double in the template but i can only define the lines to search for one time? How to do it twice?
this line to search for

<td class="subject ', $color_class2, ' windowbg2">

is 2 times on the file template around line 180 and 364 and the code around it is also the same?

I cannot declare a line of identity cos there are multiple same lines in the area to put the code between? The part to seach for(search position) and the replace would be huge then?
The result must be that the code will display the stuff i want on unreadreplies and new replies to posts template? Does my question make sence to anyone? Dont know how to explane it better in proper english...thx for the help on this one.
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

Arantor

If it's in there twice, list it twice in the file, that's the only way to do it :(

Pipke

wth that simple, why i havent think about that lol , it works! Thanks Peter.
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

Advertisement: