In this board you can talk about general questions about phpMyFAQ
Moderator: Thorsten
stingone
Posts: 25 Joined: Tue Jun 21, 2011 11:31 am
Post
by stingone » Sat Jul 09, 2011 3:31 am
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> | <a href="mysettings.php" target="content">Instellingen</a> | <a href="logout.php">Uitloggen</a>
<?php }
if (checkAdmin()) {
/*******************************END**************************/
?>
| <a href="admin.php" target="content">Beheer - Gebruikers </a> | <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
Post
by stingone » Sat Jul 09, 2011 4:09 am
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:
Post
by Thorsten » Sat Jul 09, 2011 1:41 pm
Hi,
you have to reset the template variables in an else-part
bye
Thorsten
stingone
Posts: 25 Joined: Tue Jun 21, 2011 11:31 am
Post
by stingone » Sat Jul 09, 2011 2:29 pm
How can i do this??
Thorsten
Posts: 15725 Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:
Post
by Thorsten » Sun Jul 10, 2011 1:42 pm
Hi,
you should show me your whole modifactions otherwise it'll be hard to help you.
bye
Thorsten
stingone
Posts: 25 Joined: Tue Jun 21, 2011 11:31 am
Post
by stingone » Sun Jul 10, 2011 5:22 pm
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:
Post
by Thorsten » Sun Jul 10, 2011 6:59 pm
Hi,
you have to inject the $links_template_vars variable into the template set of index.php
bye
Thorsten
stingone
Posts: 25 Joined: Tue Jun 21, 2011 11:31 am
Post
by stingone » Sun Jul 10, 2011 7:17 pm
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:
Post
by Thorsten » Mon Jul 11, 2011 6:29 am
Hi,
the index.php file is full of it at the end of the file.
bye
Thorsten
stingone
Posts: 25 Joined: Tue Jun 21, 2011 11:31 am
Post
by stingone » Mon Jul 11, 2011 5:15 pm
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:
Post
by Thorsten » Mon Jul 11, 2011 5:36 pm
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
stingone
Posts: 25 Joined: Tue Jun 21, 2011 11:31 am
Post
by stingone » Mon Jul 11, 2011 6:01 pm
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:
Post
by Thorsten » Mon Jul 11, 2011 6:16 pm
Hi,
okay, that's correct.
Did you checked if you both if-cases are true? It looks like both were false
bye
Thorsten
stingone
Posts: 25 Joined: Tue Jun 21, 2011 11:31 am
Post
by stingone » Mon Jul 11, 2011 6:31 pm
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:
Post
by Thorsten » Mon Jul 11, 2011 6:39 pm
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