Solved

Joomla 1.5 Menu External Link using a Database Field

Posted on 2011-03-10
1
407 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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

744 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

14 Experts available now in Live!

Get 1:1 Help Now