Add Information to sidebar

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
christ2000
User
Posts: 519

Add Information to sidebar

Post by christ2000 »

Hello, i don't know if this is possible but i would like to add some info to the sidebar due now i just use the navbar

i would like to show maybe company information like phone number, fax etc

is this possible?

thanks


arbei
User
Posts: 9286

Post by arbei »

You may use Auto JS Template.


christ2000
User
Posts: 519

Post by christ2000 »

thanks i will take a look, just one question, this must be used on client script?

thanks


arbei
User
Posts: 9286

Post by arbei »

Auto JS Template is client side JavaScript.


christ2000
User
Posts: 519

Post by christ2000 »

so i can use under Global, Pages with header and footer?


christ2000
User
Posts: 519

Post by christ2000 »

thanks your link help me, do you know any place to learn how to get data from mysql using javascript?

thanks


mobhar
User
Posts: 11660

Post by mobhar »

As the documentation said, you can use Auto JS Template in Page_Head or Page_Foot server event.

Since the code will be placed in layout.php file, then you may use/mix PHP code with Javascript code. See the example from documentation.


christ2000
User
Posts: 519

Post by christ2000 »

Hello, thanks for recomendation, after read i see on Page_Head i can reach what i need, but i cant find a solution to read the variable inside my code, this is my test code:

<?php $companyname = ExecuteScalar("SELECT Phrase FROM messagestemplates WHERE PhraseID=9");?>

<script type="text/html" class="ew-js-template" data-name="myDropdown" data-method="appendTo" data-target=".brand-container" data-seq="10">

<p>$companyname</p>;
</script>

when i load the page system just show $companyname and not the company name, so my code it is wrong, any help on this?

thanks


arbei
User
Posts: 9286

Post by arbei »

You need to echo your value out.


mobhar
User
Posts: 11660

Post by mobhar »

Simply change this code:
<p>$companyname</p>;

to:
<p><?php echo $companyname; ?></p>


christ2000
User
Posts: 519

Post by christ2000 »

Thanks both, i found a solution

<?php
    $varname = ExecuteScalar("SELECT `Phrase` FROM `messagestemplates` WHERE PhraseID=9");
    $varinfo = ExecuteScalar("SELECT `Phrase` FROM `messagestemplates` WHERE PhraseID=8");
?>

<script type="text/html" class="ew-js-template" data-name="logo" data-method="appendTo" data-target=".brand-container" data-seq="10">
<img src="/images/logo.png" alt="logo">
<hr class="solid">
</script>


<script type="text/html" class="ew-js-template" data-name="compinfo" data-method="appendTo" data-target=".sidebar" data-seq="10">
  <div class="scontainer">
 
<p style="color:#1370c1; font-weight:bold">Company:</br><?php echo $varname; ?></p>
<p style="color:#1370c1; font-weight:bold">Company Information:</br><?php echo $varinfo; ?></p>
<hr class="solid">
</div>

</script>
<script type="text/html" class="ew-js-template" data-name="sline" data-method="prependTo" data-target=".scontainer" data-seq="10">
<hr class="solid">
</script>

and css

.scontainer{
position: absolute;
bottom: 0;
height:450px;
left: 15px;
right: 0px;

}

Post Reply