General Community > Scripting Help

Help adding code to index.template.php

(1/1)

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.


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

--- End code ---

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


--- Code: ---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>';

--- End code ---

I end up getting a Template Parse Error!


--- Quote ---There 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 (\).
--- End quote ---

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

--- End quote ---

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
--- Code: --- <font face='Verdana, Arial, Helvetica, sans-serif' size='1'>
--- End code ---

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


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

Navigation

[0] Message Index

Go to full version