-1

I am trying to use the html code with angular elements on home page of a php forum script. I am adding this php code into index.template.php ( as supposed to be ). But it does not display anything.

<?php

/**
  * Will help you change font and colour on your forum without change templates or making CSS edits.

 */

function template_colour_picker()

{
global $txt;

echo'
<html>'

  <div id="colourpicker" ng-app="myApp" ng-controller="ngPicky">    

      <label>$txt['font']</label>  
          <input type="text" ng-model="fontName" placeholder="$txt['Enter font name here']">
       <label>$txt['color']</label> 
          <input type="text" ng-model="fontColour" placeholder="$txt['Enter colour name here']">
       <label>$txt['background']</label> 
          <input type="text" ng-model="bgColour" placeholder="$txt'[Enter backgroundcolour name here']">
          <hr>
          <div class="{{fontName}} {{fontColour}} {{bgColour}}">$txt['Text']</div>
</div>
'</html>';

}

?>

Parse error: syntax error, unexpected 'ng' (T_STRING), expecting ',' or ';' in .../themes/Silk_af_v155/index.template.php on line 405

Suresh
  • 3
  • 4

1 Answers1

1

You have all kinds of concatenation errors. Pay careful attention to where you have your single quotes (') and periods (.). Check yours against this:

<?php
function template_colour_picker()
    {
        global $txt;
        echo '
        <html>
        <div id="colourpicker" ng-app="myApp" ng-controller="ngPicky">    
            <label>'.$txt['font'].'</label>  
            <input type="text" ng-model="fontName" placeholder="'.$txt['Enter font name here'].'">
            <label>'.$txt['color'].'</label> 
            <input type="text" ng-model="fontColour" placeholder="'.$txt['Enter colour name here'].'">
            <label>'.$txt['background'].'</label> 
            <input type="text" ng-model="bgColour" placeholder="'.$txt['Enter backgroundcolour name here'].'">
            <hr>
            <div class="{{fontName}} {{fontColour}} {{bgColour}}">'.$txt['Text'].'</div>
        </div>
        </html>';
    }
Rasclatt
  • 12,498
  • 3
  • 25
  • 33
  • Many thanks @Rasclatt . The error has vanished. But the page is not displaying anything from the html. Does php allow use of as it should be ? – Suresh Oct 13 '15 at 05:01
  • If you view source, is there HTML there? – Rasclatt Oct 13 '15 at 05:07
  • Also, are these really keys from an array: `'Enter colour name here'`, `'Enter font name here'`, etc? – Rasclatt Oct 13 '15 at 05:08
  • Sadly, no. There is nothing called ngPicky in the source. – Suresh Oct 13 '15 at 05:13
  • I think you need to add more to your code above on how you are using this function. – Rasclatt Oct 13 '15 at 05:14
  • To be frank, I just want to use html code in the home page. I was suggested to use a function in index.template.php – Suresh Oct 13 '15 at 05:19
  • Does your page require dynamic input from the `$txt` array? Is there such an array even? – Rasclatt Oct 13 '15 at 05:20
  • I apologize. I should have told you my php knowledge is very poor. Since I was told to use a function, I tried to imitate a function in another template which had a .txt – Suresh Oct 13 '15 at 05:22
  • Can you post all your script that you have so far for your page in an edit? It would be helpful to see what you are trying to do, because it sounds like you are not sure yourself what you are trying to do. – Rasclatt Oct 13 '15 at 05:25
  • I simply want to display output of

    Text
    on home page.
    – Suresh Oct 13 '15 at 05:30
  • Contents of home page is decided by a template called index.template.php – Suresh Oct 13 '15 at 05:31
  • I have angularjs and ngPicky plugin added to the software. Both are getting loaded as well. – Suresh Oct 13 '15 at 05:32
  • Ok, well unfortunately that is where my expertise stops. But, if you want to write html on the page, just write what you have. You don't need a function. A function is useful if you are trying to do dynamic things to your page. – Rasclatt Oct 13 '15 at 05:34
  • Thanks. Simply add HTML on php file ? No need for echo and all ? – Suresh Oct 13 '15 at 05:36
  • Yes, simply write the HTML like you normally would on a page with a `.htm` extension. PHP will run it as normal HTML. – Rasclatt Oct 13 '15 at 05:38
  • When I add on bottom of php file, it does run. But the page loads very slow and html is displayed on top. – Suresh Oct 13 '15 at 05:40
  • Do you mind joining me at adminforum.in for sometime. I would like to share some screen shots with you and the comment system here is very limited. – Suresh Oct 13 '15 at 05:41
  • It's on local host. :( – Suresh Oct 13 '15 at 05:42
  • Sure show me whatever – Rasclatt Oct 13 '15 at 05:44
  • Thank you. My user name is wizard there. I will start a thread in a moment. – Suresh Oct 13 '15 at 05:47