Author Topic: Little question / Kleine Frage  (Read 4015 times)

0 Members and 1 Guest are viewing this topic.

Offline trez

  • Hero Member
  • *****
  • Posts: 613
    • View Profile
    • blog / photography
Little question / Kleine Frage
« on: September 11, 2006, 10:14:38 PM »
Deutsch:

Ich moechte auf einem template einen link anzeigen lassen, der aber am ende die user_id vom jeweiligen user haben muss.

Beispiel (im template):

a href="example.php?action={user_id}"

Auf der seite wuerde das dann so aussehen : action=1111 (nur beispiel)

wie mach ich das ? :)

English

I want to show a link on a template, wich contains on the end the user_id from the user, who is logged in

Exapmple

a href="example.php?action={user_id}"

So on the browser it would be the following : action=1111 (if 1111 is the user_id from the user currently logged in)

How can i make this?

Offline mawenzi

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: Little question / Kleine Frage
« Reply #1 on: September 11, 2006, 10:32:29 PM »
... Link mit der ID des aktuellen Users ...
... in der entsprechenden php-Datei etwa wie folgt ...
Code: [Select]
global $user_info;
$user_link_id = $user_info['user_id'];
$site_template->register_vars(array(
"user_link_id" => $user_link_id,
));

... damit könntest du in der gewünschten html-Datei der Link wie folgt erzeugen ...
Code: [Select]
<a href="example.php?action={user_link_id}">Linkname</a>
« Last Edit: September 11, 2006, 10:58:30 PM by mawenzi »
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline trez

  • Hero Member
  • *****
  • Posts: 613
    • View Profile
    • blog / photography
Re: Little question / Kleine Frage
« Reply #2 on: September 11, 2006, 10:37:53 PM »
Danke fuer deine hilfe, allerdings bekomm ich fehlermeldungen :(

Hier ist die datei in der ich es einfuegen will:

Code: [Select]
<?php
/**************************************************************************
 entfernt fuer diesen post
 *************************************************************************/


$main_template 'admin';

define('GET_CACHES'1);
define('ROOT_PATH''./');
define('GET_USER_ONLINE'1);
include(
ROOT_PATH.'global.php');
require(
ROOT_PATH.'includes/sessions.php');
include(
ROOT_PATH.'mini_top.php');

$user_access get_permission();


if (isset(
$HTTP_GET_VARS['template']) || isset($HTTP_POST_VARS['template'])) {
  
$template = (isset($HTTP_POST_VARS['template'])) ? basename(stripslashes($HTTP_POST_VARS['template'])) : basename(stripslashes($HTTP_GET_VARS['template']));
  if (!
file_exists(TEMPLATE_PATH."/".$template.".".$site_template->template_extension)) {
    
$template "";
  }
  else {
    
$main_template $template;
  }
}
else {
  
$template "";
}
include(
ROOT_PATH.'includes/page_header.php');




ob_start();


global 
$user_info;
$user_link_id $user_info['user_id']
$site_template->register_vars(array(
"user_link_id" => $user_link_id,
));

//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  
"msg" => $msg,
  
"clickstream" => $clickstream,
  
"rating" => $user_info['user_rating'],
  
"votes" => $user_info['user_votes'],
  
"rating_pic" => ceil($user_info['user_rating']),
));
if (
$news_type == "latestnewsall") {  
 
$site_template->print_template($site_template->parse_template(archive));      
}  
else {  
 
$site_template->print_template($site_template->parse_template($main_template));  
}

$content ob_get_contents();
ob_end_clean();

if (
$cache_page_index) {
  
// Reset session mode
  
$site_sess->mode $old_session_mode;

  
save_cache_file($cache_id$content);
}

echo 
$content;

include(
ROOT_PATH.'includes/page_footer.php');
?>


Offline mawenzi

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: Little question / Kleine Frage
« Reply #3 on: September 11, 2006, 11:04:40 PM »
... hatte ein semikolon vergessen ...
... ist im code oben berichtigt ...

da die "global $user_info" in deiner Datei schon aufgerufen sein sollte ... kannst du die ganze Sache auch verkürzen ... indem du einfach  nach ...
Code: [Select]
"votes" => $user_info['user_votes'],
folgendes einfügst
Code: [Select]
"user_link_id" => $user_info['user_id'],

« Last Edit: September 12, 2006, 02:23:41 PM by mawenzi »
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline trez

  • Hero Member
  • *****
  • Posts: 613
    • View Profile
    • blog / photography
Re: Little question / Kleine Frage
« Reply #4 on: September 11, 2006, 11:16:41 PM »
hm, hab e so gemacht, hab jetzt zwar keine fehlermeldung, allerdings wird die user_id nicht angegeben.

So ist es im template: /member.php?action=blah{user_link_id}

Wenn ich jetzt allerdings mit der maus ueber den link fahre, bekomm ich nur das:

member.php?action=blah

Danke fuer deine hilfe ;)

Offline trez

  • Hero Member
  • *****
  • Posts: 613
    • View Profile
    • blog / photography
Re: Little question / Kleine Frage
« Reply #5 on: September 11, 2006, 11:19:09 PM »
ups, habs rausgefunden ;)

anstatt

Code: [Select]
$user_link_id = $user_info['user_id'],

das hier ;)

Code: [Select]
"user_link_id" => $user_info['user_id'],

Danke nochmal :)

Question resolved

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Little question / Kleine Frage
« Reply #6 on: September 11, 2006, 11:24:29 PM »
* V@no with no manners enters into conversation

Code: [Select]
global $user_info;
$user_link_id = $user_info['user_id'];
$site_template->register_vars(array(
"user_link_id" => $user_link_id,
));
can be simplify and would save 0.001 second of php compilation time with this:
Code: [Select]
$site_template->register_vars("user_link_id", $user_info['user_id']);
(in this case global $user_info; is not needed)

* V@no leaves without saying bye. what a jerk!
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)