News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Help adding code to index.template.php

Started by ApplianceJunk, April 14, 2012, 02:35:45 PM

Previous topic - Next topic

ApplianceJunk

I'm just playing around trying to learn more about how the SMF code works.

When I add this code to the index.template.php just above template_menu(); it works.


echo'
<div>
<table>
<tr>
  <td>
    <a href="http://appliancejunk.com">ApplianceJunk.com</a>
  </td>
</tr>
</table>
</div>';


So then I try to insert a form in place of the table using this code, but it don't work, why?


echo'
<div>
<form name='SmartSearch' method='get' target='_tab' action='http://www.repairclinic.com/Shop-For-Parts'>
<table width='611'>
  <tr>
    <td>
      <font face='Verdana, Arial, Helvetica, sans-serif' size='1'>
        Please enter part or model number: </font>
      <p align='left'>
      <input type='hidden' value='24039' name ='RCAID' />
      <input type='text' id='searchText' NAME='searchText' size='30' maxLength='80' />
      <INPUT type='submit' value='Search' name='Search'><br />
      </p>
    </td>
  </tr>
</table>
</form>
</div>';


I end up getting a Template Parse Error!

QuoteThere was a problem loading the /Themes/default/index.template.php template or language file. Please check the syntax and try again - remember, single quotes (') often have to be escaped with a slash (\).

I tried adding a \ but I just don't know what I'm doing.






Shambles

I'd be tempted to use double quotes all the way through/within the echo clause, or the parser might get confused

ApplianceJunk

Quote from: Shambles on April 14, 2012, 02:42:03 PM
I'd be tempted to use double quotes all the way through/within the echo clause, or the parser might get confused

Sorry, I'm not sure what that means.
Could you post some code as a example of what you mean?

Thanks for the reply.

Shambles

I think your extensive use of ' might cause the parser to think the echo was closed.

For example:

Find <font face='Verdana, Arial, Helvetica, sans-serif' size='1'>

Replace <font face="Verdana, Arial, Helvetica, sans-serif" size="1">


I'm no expert, it's just something that stands out to me

ApplianceJunk

I understand what you mean now, thanks!

I replaced all the ' with " and it works great now!

I just copied the code i was giving for that form from our affiliate. It always worked when I used it as is before, but I was using one of the SMF ad mods to display it instead of directly entering the code in to the index.template.php.

Thanks

Advertisement: