Solved

Joomla 1.5 Menu External Link using a Database Field

Posted on 2011-03-10
1
411 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

856 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