Solved

Joomla 1.5 Menu External Link using a Database Field

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

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

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.
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

726 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