Solved

Joomla 1.5 Menu External Link using a Database Field

Posted on 2011-03-10
1
414 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 14

Accepted Solution

by:
Allan Nisbet 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
A big percent of today’s marketing activity is performed through the online environment. The marketing strategies that have existed a decade ago no longer relate to what’s happening today. We’re currently facing a revolutionary era, called the digit…
The viewer will learn how to dynamically set the form action using jQuery.
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.

690 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