Support Forums

User's city in header

This is a discussion on User's city in header within the Templates, HTML, CSS, and Design Help forums, part of the General category; Hey, Does anybody know how to display the user's registered city on the homepage in the same way the username ...


Go Back   68 Classifieds Forums > General > Templates, HTML, CSS, and Design Help

Reply
 
Thread Tools Display Modes
Old 01-23-2009, 04:38 PM   #1
Graphic / Web Desginer
 
Join Date: Nov 2008
Location: London, England
Posts: 77
Rep Power: 10
DGiscombe is on a distinguished road
Default User's city in header

Hey,

Does anybody know how to display the user's registered city on the homepage in the same way the username is displayed in the welcome note?

I'm not sure on how to code a cookie session for that.
DGiscombe is offline   Reply With Quote
Old 01-23-2009, 06:07 PM   #2
curmudgeon
 
Join Date: Mar 2006
Posts: 5,342
Rep Power: 132
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

The login process doesnt pull any of the users address from the database when they login so to get it to display you would have to alter the login function to first collect that info. Then you would have to modify all the cookie and session related functions to include the existing data as well.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline   Reply With Quote
Old 01-23-2009, 07:10 PM   #3
Graphic / Web Desginer
 
Join Date: Nov 2008
Location: London, England
Posts: 77
Rep Power: 10
DGiscombe is on a distinguished road
Default

Would the altering of the function be in includes/classes/kernal/Login.php alone?
DGiscombe is offline   Reply With Quote
Old 01-23-2009, 07:38 PM   #4
curmudgeon
 
Join Date: Mar 2006
Posts: 5,342
Rep Power: 132
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by DGiscombe
Would the altering of the function be in includes/classes/kernal/Login.php alone?
yep. The other session and cookie functions should be in there as well.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline   Reply With Quote
Old 01-23-2009, 08:56 PM   #5
Graphic / Web Desginer
 
Join Date: Nov 2008
Location: London, England
Posts: 77
Rep Power: 10
DGiscombe is on a distinguished road
Default

Sorry to bug again, I'm not too good at coding, but I made these changes:

/**
* Update the users table session information
*
* @access private
* @return void
* @internal requires that _userData be set
*/
function _saveSession()
{
$sSQL = 'UPDATE ' . PREFIX . 'users
SET
lastlogin=NOW(),
cookie=' . $this->_db->quoteInto(md5($this->_userData['username'])) . ',
cookie=' . $this->_db->quoteInto(md5($this->_userData['country'])) . ',
session = ' . $this->_db->quoteInto(session_id()) . ',
custip = ' . $this->_db->quoteInto($_SERVER['REMOTE_ADDR']) . '
WHERE id =' . $this->_userData['id'];
$this->_db->query($sSQL);
}

/**
* Set a users session
*
* @access private
* @return void
* @internal requires that _userData be set
*/
function _setUserSession()
{
$_SESSION['uid'] = $this->_userData['id'];
$_SESSION['username'] = htmlspecialchars($this->_userData['username']);
$_SESSION['country'] = htmlspecialchars($this->_userData['country']);
$_SESSION['cookie'] = md5($this->_userData['username']);
$_SESSION['cookie'] = md5($this->_userData['country']);
$_SESSION['userlevel'] = $this->_userData['level'];
$_SESSION['logged'] = true;
$_SESSION['hash'] = $this->_hash;
}

Am I heading in the right direction here?
DGiscombe is offline   Reply With Quote
Old 01-23-2009, 10:46 PM   #6
curmudgeon
 
Join Date: Mar 2006
Posts: 5,342
Rep Power: 132
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

The changes you made simply place the a variable into a session or a cookie, but nothing you did actually collected that data from the database. Thats done by the _checklogin function (I may have that name wrong, im just going from memory).
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline   Reply With Quote
Old 01-24-2009, 09:39 PM   #7
Graphic / Web Desginer
 
Join Date: Nov 2008
Location: London, England
Posts: 77
Rep Power: 10
DGiscombe is on a distinguished road
Default

Am I adding a query in here somewhere?

function checkLogin($username, $password, $remember='N')
{
$password = $this->hashPassword($password);
if (defined('IN_ADMIN')) {
if (!$this->_checkAdminLogin($username, $password)) { //failed
$this->_checkLoginFailed();//assign error to template
return false;
}
$this->_setHash();
$this->_setAdminSession();
$this->_saveSession();
if ($remember <> 'N') {
$this->_setCookie();
}
return true;
}
if (!$this->_checkUserLogin($username, $password)) { //failed
$this->_checkLoginFailed();//assign error to template
return false;
}
if (!$this->_checkEmailValidation()) { //hasn't validated email
$this->_checkLoginFailed();//assign error to template
return false;
}
if ($this->_checkBanned()) { //banned
$this->_checkLoginFailed();//assign error to template
return false;
}
$this->_setHash();
$this->_setUserSession();
$this->_saveSession();
if ($remember <> 'N') {
$this->_setCookie();
}
return true;
}
DGiscombe is offline   Reply With Quote
Old 01-24-2009, 10:08 PM   #8
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,493
Rep Power: 132
Eric Barnes is just really nice Eric Barnes is just really nice
Default

Open Login and find the function _setUserSession().
Next inside this find:
$_SESSION['username'] = htmlspecialchars($this->_userData['username']);

Just below it add:
$_SESSION['city'] = htmlspecialchars($this->_userData['city']);

Then in the template:
{$smarty.session.city}
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 01-25-2009, 10:30 AM   #9
Graphic / Web Desginer
 
Join Date: Nov 2008
Location: London, England
Posts: 77
Rep Power: 10
DGiscombe is on a distinguished road
Default

Thanks Eric
DGiscombe is offline   Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shumen.biz - City Classified Ads SecondShoe Site Critiques 7 10-24-2008 07:58 PM
listing address different from user's addesss anna245 Technical Support 1 04-18-2008 02:42 PM
When not using Address or City Grebogreen Technical Support 2 07-05-2007 12:46 PM
User's credit ??? Unregistered Pre Sales Questions 1 06-08-2007 10:02 AM


All times are GMT -4. The time now is 12:19 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0