Solved

Joomla 1.5 Menu External Link using a Database Field

Posted on 2011-03-10
1
409 Views
Last Modified: 2012-05-11
On a Joomla 1.5 website, I need to setup a menu item external link that is specific to the logged in user and that pulls a portion or the entire URL from a database field.  So when a registered user logs into the website, on their User Menu there will be a link to say Docs, this link will have a common base URL of http://www.domain.com for all users , however the ending portion of the URL, /UsersDocs , would be specific for each user and pulled from a database field.  The other option is that the entire URL is pulled from the database field.

I know that using CB I can create the database field but how do I get the Joomla External Link to pull or reference the info from the field into the URL, I do not know what to do.

Is there a way to do this without CB or is it easier to use a CB or some other plugin?

Thanks in advance for your assistance.
0
Comment
Question by:flyboy_dea
1 Comment
 
LVL 13

Accepted Solution

by:
StormITSolutions earned 500 total points
ID: 35162075
Hi

The simple answer is yes.

Use CB to create your custom field.

//connect to your database
$db = mysql_connect("localhost",*username*,*password*) or die("Couldn't connect to the database.");

//select the database
mysql_select_db($database) or die("Couldn't select the database");

//query the database table.  $result will store the result and mysql_query will do the actual querying of the database.
$result=mysql_query("select * FROM exampletable where ID=1");

//put the results into an array called $row
$row=mysql_fetch_array($result);

//echo (display) a link using $row['ID']
echo "<a href='http://www.website.com/links.php?lc_URL=".$row['ID']."'>Click Here</a>

}  

Open in new window



This is how you would do it in php,

So the next step is to look at any joomla module which connects to database and replace the database connection info.
Then assign the sql to your field and to select the correct row in the database use the User ID as your comparison field so the link is only created for the user in the database, compare it to the current logged in user which is simpe with sql and joomla, and finally create the link.

Now the final part.

Create a custom code module and insert your finished php code and assign it to the location you want the link such as "left"

You can give the module a title and your code will create a link which will be unique to the current logged in user.

Its pretty easy tbh, if i wasnt so tired I would write it for you, but alas im off to bed : )

Storm
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we will look at our content management system as a whole, to get an idea of how we will start to manage these content items.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now