Joomla! Discussion Forums



It is currently Tue Nov 24, 2009 7:36 pm (All times are UTC )

 


Forum rules

Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.



Post new topic Reply to topic  [ 10 posts ] 
Author Message
Posted: Mon Aug 10, 2009 11:27 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast
Offline

Joined: Sun Jan 28, 2007 9:11 pm
Posts: 104
In "Joomla -> Administrator -> Site -> System", the admin can specify a value for "Path to Media Folder". What PHP code can I put in my template that would allow me to retrieve that value?

_________________
http://FunAndEducational.com - My Joomla site
Where to hire freelancers:: http://www.learnwebdesignonline.com/resources/business-jobs/where-find-freelancers


Top
  E-mail  
 
Posted: Tue Aug 11, 2009 2:11 am 
User avatar
Joomla! Hero
Joomla! Hero
Offline

Joined: Thu Jul 24, 2008 12:48 pm
Posts: 2067
Location: Austin, TX
Searching through the code, I found a few places that do something like this:

.../templates/beez/html/com_content/category/blog.php
Code:
$cparams = JComponentHelper::getParams ('com_media');
...
$cparams->get('image_path');


I think the parameter you want is file_path:
.../administrator/components/com_media/config.xml

So you would do something like:
Code:
$cparams = JComponentHelper::getParams ('com_media');
...
$cparams->get('file_path');


Let me know if you get it working. I haven't tested it myself.

_________________
Will Mavis - Joomla Extension Developer
http://www.cmsmarket.com/
http://www.sourcecoast.com/
If you think I can help you, feel free to PM me a link to your post and I will respond. Please don't hijack another user's thread. :D


Top
  E-mail  
 
Posted: Tue Aug 11, 2009 5:25 am 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast
Offline

Joined: Sun Jan 28, 2007 9:11 pm
Posts: 104
It works. Thanks.

I used a more concise form ...

Code:
JComponentHelper::getParams('com_media')->get('file_path');

_________________
http://FunAndEducational.com - My Joomla site
Where to hire freelancers:: http://www.learnwebdesignonline.com/resources/business-jobs/where-find-freelancers


Top
  E-mail  
 
Posted: Tue Aug 11, 2009 4:25 pm 
User avatar
Joomla! Hero
Joomla! Hero
Offline

Joined: Thu Jul 24, 2008 12:48 pm
Posts: 2067
Location: Austin, TX
Cool. Glad it worked!

_________________
Will Mavis - Joomla Extension Developer
http://www.cmsmarket.com/
http://www.sourcecoast.com/
If you think I can help you, feel free to PM me a link to your post and I will respond. Please don't hijack another user's thread. :D


Top
  E-mail  
 
Posted: Thu Nov 05, 2009 9:26 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Fri Sep 18, 2009 8:26 pm
Posts: 9
Hoping you can help with similar request. I am trying to use image set in the menu to display elsewhere, but for the life of me I can't find it. I can see the param in MySQL table jos_menu, but I can't get it directly from com_menu ... the following doesn't work:
Code:
$article_image = &JComponentHelper::getParams( 'com_menus' )->get( 'menu_image' );

but this does, with custom param in com_content (from viewtopic.php?f=178&t=320017):
Code:
$article_image = &JComponentHelper::getParams( 'com_content' )->get( 'article_image' );

Thanks!


Top
  E-mail  
 
Posted: Thu Nov 05, 2009 10:19 pm 
User avatar
Joomla! Hero
Joomla! Hero
Offline

Joined: Thu Jul 24, 2008 12:48 pm
Posts: 2067
Location: Austin, TX
I'm guessing that the menu_image parameter is associated with the menu item and not the actual component. If you let me know where you are trying to use this, I might be able to help.

For a reference, I would look at the mod_mainmenu code:
.../modules/mod_mainmenu/helper.php
Code:
$iParams = new JParameter($tmp->params);
if ($params->get('menu_images') && $iParams->get('menu_image') && $iParams->get('menu_image') != -1) {
...
   $image = '<img src="'.JURI::base(true).'/images/stories/'.$iParams->get('menu_image').'" '.$imgalign.' alt="'.$item->alias.'" />';


Let me know if you need more help figuring it out.

_________________
Will Mavis - Joomla Extension Developer
http://www.cmsmarket.com/
http://www.sourcecoast.com/
If you think I can help you, feel free to PM me a link to your post and I will respond. Please don't hijack another user's thread. :D


Top
  E-mail  
 
Posted: Fri Nov 06, 2009 12:57 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Fri Sep 18, 2009 8:26 pm
Posts: 9
Really appreciate the help! You are correct, what I am after is associated with the menu item param menu_image. I want to display it in the root template index.php file \templates\custom\index.php (I have modified the ja_purity template thinking it would be easy to support and update going forward).

I'm very familiar with php and MySQL so this simple function is very frustrating for me. I'm new to joomla and so far unable to find anything to help me query the database in the documents / forums. I need to know how to query the database and I'm thinking that joomla has an easier method than making standard mysql_query ... am I right?


Top
  E-mail  
 
Posted: Fri Nov 06, 2009 2:26 am 
User avatar
Joomla! Hero
Joomla! Hero
Offline

Joined: Thu Jul 24, 2008 12:48 pm
Posts: 2067
Location: Austin, TX
You are correct:
http://api.joomla.org/Joomla-Framework/Database/JDatabase.html

And there are some other classes that might have functions that would interest you:
http://api.joomla.org/Joomla-Framework/Application/JApplication.html#getMenu

I would really suggest looking through the mod_mainmenu to see how they are doing things and try to borrow from them.

If you have any specific questions or need more help, let me know.

_________________
Will Mavis - Joomla Extension Developer
http://www.cmsmarket.com/
http://www.sourcecoast.com/
If you think I can help you, feel free to PM me a link to your post and I will respond. Please don't hijack another user's thread. :D


Top
  E-mail  
 
Posted: Fri Nov 06, 2009 3:40 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Fri Sep 18, 2009 8:26 pm
Posts: 9
Thank You! You really know how to point a guy in the right direction. I found the answer I was looking for by searching jmenu, though the documantaion is pretty much empty it pointed me to /libraries/joomla/application/menu.php - which is the same as the Developer API link you provided.... and then it all came together with the forum post and solution here viewtopic.php?f=304&t=259391&start=0

The following code in the template root index.php file will get the active menu_image. This code along with the code for getting custom article images is my ideal soultion as I now have a header picture for every page either from the menu or the articles themselves. It's a beautiful thing!

Code:
$menu       =& JSite::getMenu();
$item       =  $menu->getActive();
$params     =& $menu->getParams($item->id);
$menu_image =  $params->get( 'menu_image' );


Top
  E-mail  
 
Posted: Fri Nov 06, 2009 4:30 am 
User avatar
Joomla! Hero
Joomla! Hero
Offline

Joined: Thu Jul 24, 2008 12:48 pm
Posts: 2067
Location: Austin, TX
Awesome. Glad I could help.

I use the api.joomla.org site a lot to quickly see function definitions, but it's nice to just be able to open the files themselves and look directly at the code. One of the many benefits of Open Source!

_________________
Will Mavis - Joomla Extension Developer
http://www.cmsmarket.com/
http://www.sourcecoast.com/
If you think I can help you, feel free to PM me a link to your post and I will respond. Please don't hijack another user's thread. :D


Top
  E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

Quick reply

 



Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group