Page 1 of 1

Add Information to sidebar

Posted: Wed Feb 01, 2023 9:56 am
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


Re: Add Information to sidebar

Posted: Wed Feb 01, 2023 10:00 am
by arbei

You may use Auto JS Template.


Re: Add Information to sidebar

Posted: Wed Feb 01, 2023 10:06 am
by christ2000

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

thanks


Re: Add Information to sidebar

Posted: Wed Feb 01, 2023 10:06 am
by arbei

Auto JS Template is client side JavaScript.


Re: Add Information to sidebar

Posted: Wed Feb 01, 2023 10:09 am
by christ2000

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


Re: Add Information to sidebar

Posted: Wed Feb 01, 2023 10:44 am
by christ2000

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

thanks


Re: Add Information to sidebar

Posted: Wed Feb 01, 2023 1:32 pm
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.


Re: Add Information to sidebar

Posted: Fri Feb 03, 2023 6:57 am
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


Re: Add Information to sidebar

Posted: Fri Feb 03, 2023 9:03 am
by arbei

You need to echo your value out.


Re: Add Information to sidebar

Posted: Fri Feb 03, 2023 9:05 am
by mobhar

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

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


Re: Add Information to sidebar

Posted: Sat Feb 04, 2023 9:31 am
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;

}