4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: lakeside on May 08, 2003, 06:30:42 PM
-
Hi,
Can someone write me a small snippet of php coding that I can place in all my necessary php files that will do the following:
Get the users logged in name.
Check the mysql database for any category that is the same as the username
return the category #id of that matching category.
Basically I just want to have a direct link in the logininfo.html file so that when a user logs in, they have a direct link to the category that is the same as thier username.
On my system when a user registers I create a category with the same name as the user, and give only that user permission to upload, so it's their private category which is the same name as their logged in username.
Thanks,
-
Well V@no just did a mod private category... AMybe this is what u are looking 4...
-
Thanks, No, thats too elaborate for my system, also it doesnt incoporate some other mods that i have in mine.
I just need a direct link to a category that is the same as the users name, even an alteration of the search function to search by category name and return that category would work I think.
-
well, then try this one:
in /includes/page_header.php find:
$site_template->register_vars(array(
that must be the first one from the top of the file ;)
replace it with:$user_cat_id = "";
foreach($cat_cache as $key => $val){
if ("General" == $cat_cache[$key]['cat_name']) {
$user_cat_id = $key;
break;
}
}
$site_template->register_vars(array(
"user_cat_url" => ($user_cat_id) ? "» <a href=\"".$site_sess->url(ROOT_PATH."categories.php?cat_id=".$user_cat_id)."\">My category</a><br />" : "",
now u can use in any templates this tag:
{user_cat_url}
P.S. this is case sencetive, so if username is "Jack" and category name is "jack" it wont work.
-
Thanks,
I put the following in page_header.php in my includes directory:
//-----------------------------------------------------
//--- Register Global Vars ----------------------------
//-----------------------------------------------------
$total_images = 0;
$total_categories = 0;
$auth_cat_sql['auth_viewcat']['IN'] = 0;
$auth_cat_sql['auth_viewcat']['NOTIN'] = 0;
if (!empty($cat_cache)) {
foreach ($cat_cache as $key => $val) {
if (check_permission("auth_viewcat", $key)) {
$total_categories++;
if (isset($val['num_images'])) {
$total_images += $val['num_images'];
}
else {
$cat_cache[$key]['num_images'] = 0;
}
$auth_cat_sql['auth_viewcat']['IN'] .= ", ".$key;
}
else {
$auth_cat_sql['auth_viewcat']['NOTIN'] .= ", ".$key;
}
}
}
$user_cat_id = "";
foreach($cat_cache as $key => $val){
if ("General" == $cat_cache[$key]['cat_name']) {
$user_cat_id = $key;
break;
}
}
$site_template->register_vars(array(
"user_cat_url" => ($user_cat_id) ? "» <a href=\"".$site_sess->url(ROOT_PATH."categories.php?cat_id=".$user_cat_id)."\">My category</a>" : "",
"media_url" => MEDIA_PATH,
"thumb_url" => THUMB_PATH,
"icon_url" => ICON_PATH,
"template_url" => TEMPLATE_PATH,
"template_image_url" => TEMPLATE_PATH."/images",
I left in the top bit so you can see where I put it.
Now in my user_logininfo.html template I put {user_cat_url}
But then I login, and the user_logininfo.html doesnt show anything for {user_cat_url} its just a blank area.
What did I do wrong? Theres no errors, its just blank where it should show My Category :
-
Okay, I figured out part of it.
General needs to be changed to the parent category.
But my category structure is like
Users Galleries (main category)
A (Sub category under Users Galleries)
Anton (Sub Category under the A Subcategory)
I think this wont read past the main category, because now that I changed General to Users Galleries, it always gives back the same cat id of 30, which is what Users Galleries is in my database.
Help. :(
Okay just tried something though,
I took the lakeside category and made it a subcategory of my Users Galleries
So it goes like this:
Users Galleries (main category)
lakeside (sub category under Users Galleries)
But it still only brings back the cat id of the Users Galleries and not lakeside category when logged in as lakeside.
-
V@no, do you know what I did wrong here?
-
V@no, do you know what I did wrong here?
ops...I'm sorry, I posted code from my "test" script...so, u must replace: if ("General" == $cat_cache[$key]['cat_name']) {
with: if ($user_info['user_name'] == $cat_cache[$key]['cat_name']) {
-
EXCELLENT! My everlasting thanks for this, this was the number one requested feature of our registered users.