Add php into phpmyfaq

In this board you can talk about general questions about phpMyFAQ

Moderator: Thorsten

stingone
Posts: 25
Joined: Tue Jun 21, 2011 11:31 am

Add php into phpmyfaq

Post by stingone »

Hi all,

I have a loginscript and what i want is that when people logged in succesfully the script below shows up in phpmyfaq. How can i manage this? i have no idea where to insert it. Or even how i can integrate this in the left menu for example

Code: Select all

<?php 
if (isset($_SESSION['user_id'])) {?>
    </strong> <a href="myaccount.php" target="_parent">Home</a>&nbsp;| <a href="mysettings.php" target="content">Instellingen</a>&nbsp;| <a href="logout.php">Uitloggen</a>
<?php }
if (checkAdmin()) {
/*******************************END**************************/
?>
| <a href="admin.php" target="content">Beheer - Gebruikers </a>&nbsp;| <a href="admin/index.php" target="_new"> Beheer - FAQ </a>
<?php } ?>
So is it for example possible to add {loginmenu} to the index.tpl in the header, but that that {loginmenu} whill showup if

Code: Select all

<?php 
if (isset($_SESSION['user_id'])) {?>
????
stingone
Posts: 25
Joined: Tue Jun 21, 2011 11:31 am

Re: Add php into phpmyfaq

Post by stingone »

I now tried this

Code: Select all

if (isset($_SESSION['user_id'])) {
	$links_template_vars = array(
   "test"          	  => '<a href="index.php?'.$sids.'action=test">Test</a>');
}

if (checkAdmin()) {
	$links_template_vars = array(
   "test1"          	  => '<a href="index.php?'.$sids.'action=test">Test1</a>');
}
But if the admin is no the {test} shows up instead of hidding the {test} in index.tpl
Thorsten
Posts: 15725
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Add php into phpmyfaq

Post by Thorsten »

Hi,

you have to reset the template variables in an else-part

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
stingone
Posts: 25
Joined: Tue Jun 21, 2011 11:31 am

Re: Add php into phpmyfaq

Post by stingone »

How can i do this??
Thorsten
Posts: 15725
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Add php into phpmyfaq

Post by Thorsten »

Hi,

you should show me your whole modifactions otherwise it'll be hard to help you.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
stingone
Posts: 25
Joined: Tue Jun 21, 2011 11:31 am

Re: Add php into phpmyfaq

Post by stingone »

What i did in the index.tpl

Code: Select all

{allCategories}
{showInstantResponse}
{msgAddContent}
{msgQuestion}
{msgOpenQuestions}
{showSitemap}
{msgContact}
{test}
Than define in de constant.php add to

Code: Select all

$allowedVariables = array( 
    'test'       => 1
Than add to index.php

Code: Select all

if (isset($_SESSION['user_id'])) {
   $links_template_vars = array(
   "test"               => '<a href="../login/logout.php">Test</a>');
}
but it shows up all the time now as {test} so it does nothing.
Thorsten
Posts: 15725
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Add php into phpmyfaq

Post by Thorsten »

Hi,

you have to inject the $links_template_vars variable into the template set of index.php

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
stingone
Posts: 25
Joined: Tue Jun 21, 2011 11:31 am

Re: Add php into phpmyfaq

Post by stingone »

Hi Thorsten,

Can you maybe give me a example of how to do this properly?
Thorsten
Posts: 15725
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Add php into phpmyfaq

Post by Thorsten »

Hi,

the index.php file is full of it at the end of the file. :-)

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
stingone
Posts: 25
Joined: Tue Jun 21, 2011 11:31 am

Re: Add php into phpmyfaq

Post by stingone »

Thorsten wrote:Hi,

the index.php file is full of it at the end of the file. :-)

bye
Thorsten
Sorry for asking again.

but what i do below is that not injecting the php?? i dont know what i need to change.....again sorry for asking.

Code: Select all

if (isset($_SESSION['user_id'])) {
   $links_template_vars = array(
   "test"               => '<a href="index.php?'.$sids.'action=test">Test</a>');
}

if (checkAdmin()) {
   $links_template_vars = array(
   "test1"               => '<a href="index.php?'.$sids.'action=test">Test1</a>');
}
in the top of index.php i have that checks the code above. but it doesnt work in this way it still shows only the {test} {test1}

Code: Select all

<?php 
include '../login/dbc.php';
page_protect();
session_start();

?>
Thorsten
Posts: 15725
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Add php into phpmyfaq

Post by Thorsten »

Hi,

where did you add this code? Which file and which line number?

Code: Select all

if (isset($_SESSION['user_id'])) {
   $links_template_vars = array(
   "test"               => '<a href="index.php?'.$sids.'action=test">Test</a>');
}

if (checkAdmin()) {
   $links_template_vars = array(
   "test1"               => '<a href="index.php?'.$sids.'action=test">Test1</a>');
}
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
stingone
Posts: 25
Joined: Tue Jun 21, 2011 11:31 am

Re: Add php into phpmyfaq

Post by stingone »

Thorsten wrote:Hi,

where did you add this code? Which file and which line number?

Code: Select all

if (isset($_SESSION['user_id'])) {
   $links_template_vars = array(
   "test"               => '<a href="index.php?'.$sids.'action=test">Test</a>');
}

if (checkAdmin()) {
   $links_template_vars = array(
   "test1"               => '<a href="index.php?'.$sids.'action=test">Test1</a>');
}
bye
Thorsten
I added the code into index.php of version 2.7 on line 491. and enterd {test} and {test1} in the index.tpl
Thorsten
Posts: 15725
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Add php into phpmyfaq

Post by Thorsten »

Hi,

okay, that's correct.

Did you checked if you both if-cases are true? It looks like both were false

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
stingone
Posts: 25
Joined: Tue Jun 21, 2011 11:31 am

Re: Add php into phpmyfaq

Post by stingone »

Thorsten wrote:Hi,

okay, that's correct.

Did you checked if you both if-cases are true? It looks like both were false

bye
Thorsten
Yes both cases are true. So i login with a script that goes ok. Then the include file on the top of index.php checks if the user is login and if it is admin or not.

If it is a user who is logged in it shows the menu in {test} and if the user is also admin it shows {test1}

its just if it does not give any output to the index.tpl ... im little bit lost now
Thorsten
Posts: 15725
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Add php into phpmyfaq

Post by Thorsten »

Hi,

please try this:

Code: Select all

if (isset($_SESSION['user_id'])) {
   $links_template_vars = array(
   "test"               => '<a href="index.php?'.$sids.'action=test">Test</a>');
} else {
   $links_template_vars = array(
   "test"               => 'not true');
}

if (checkAdmin()) {
   $links_template_vars = array(
   "test1"               => '<a href="index.php?'.$sids.'action=test">Test1</a>');
} else {
   $links_template_vars = array(
   "test"               => 'not true');
}
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Post Reply