Creating a Legend for Categories, need help
- cmtrig
- Topic Author
- Offline
- Senior Member
Less
More
4 years 9 months ago #125975
by cmtrig
Charlie Trig, Trig Web Design
www.trigwebdesign.com
Creating a Legend for Categories, need help was created by cmtrig
Hi Pham, how you doing? I am creating a LEGEND for all Categories in Event Booking and I have most of the code complete, but I am stuck on one thing. for some reason, no matter what php code I try, I cannot get the color_code and text_color fields out of the database. I can populate the title and description, but any call to 'color_code' comes back blank. I have color assignments for every category.
I am editing mod_eb_category.php
Can you please tell me what php code I can insert like a $sql_query to #__eb_categories, and echo $row->color_code? I am setting up boxes next to category names that will show the background color assigned to the category, if it is set.
// trying to get category color
$result = mysqli_query("SELECT color_code FROM #__eb_categories WHERE id='" . $row->id . "'");
$ccode = mysqli_fetch_assoc($result);
$cc = $ccode;
echo $cc;
This is not working, I have tried several variations with no result. Once this is programmed, I am sure others will use it, I found a number of requests on your forum about this.
I am editing mod_eb_category.php
Can you please tell me what php code I can insert like a $sql_query to #__eb_categories, and echo $row->color_code? I am setting up boxes next to category names that will show the background color assigned to the category, if it is set.
// trying to get category color
$result = mysqli_query("SELECT color_code FROM #__eb_categories WHERE id='" . $row->id . "'");
$ccode = mysqli_fetch_assoc($result);
$cc = $ccode;
echo $cc;
This is not working, I have tried several variations with no result. Once this is programmed, I am sure others will use it, I found a number of requests on your forum about this.
Charlie Trig, Trig Web Design
www.trigwebdesign.com
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
4 years 9 months ago #125980
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Creating a Legend for Categories, need help
Hello
The code below should give you the data you need
Regards,
Tuan
The code below should give you the data you need
Code:
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('color_code')
->from('#__eb_categories')
->where('id = '.$row->id);
$db->setQuery($query);
$colorCode = $db->loadResult();
Regards,
Tuan
Please Log in or Create an account to join the conversation.
- cmtrig
- Topic Author
- Offline
- Senior Member
4 years 9 months ago #125986
by cmtrig
Charlie Trig, Trig Web Design
www.trigwebdesign.com
Replied by cmtrig on topic Creating a Legend for Categories, need help
That works! I will now construct the legend using the background colors assigned to the category. I will post my solution here for all to use when it's done! Thanks Tuan!
Charlie Trig, Trig Web Design
www.trigwebdesign.com
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
4 years 9 months ago #126013
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Creating a Legend for Categories, need help
Great. Thanks
Tuan
Tuan
Please Log in or Create an account to join the conversation.
Moderators: Tuan Pham Ngoc
Support
Documentation
Information
Copyright © 2024 Joomla Extensions by Joomdonation. All Rights Reserved.
joomdonation.com is not affiliated with or endorsed by the Joomla! Project or Open Source Matters.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.