Class problem

A meet-and-greet for our aspiring developers looking for like minded souls to share inspiring ideas and concepts related to Joomla! development. Discuss your apps, gather your team, and get ready to code!

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
Muneo
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Fri Aug 19, 2005 3:02 am
Location: Brazil
Contact:

Class problem

Post by Muneo » Wed Nov 21, 2007 1:50 pm

I am developing a module that print select form. So, I am trying to use JHTMLSelect (in /tmpl/default.php), but the system give the follow error:
Fatal error:  Class 'JHTMLSelect' not found in...

The code is:

Code: Select all

foreach ($weblinks as $link) : 
   echo JHTMLSelect::option($link->url, $link->url);
endforeach;


It's seems that this class (JHTMLSelect) doesn't load correctly...
Can Someone Help me? Thank you...
Jorge Muneo Nakagawa
http://muneo.joanopolis.com.br

User avatar
ircmaxell
Joomla! Intern
Joomla! Intern
Posts: 52
Joined: Thu Nov 10, 2005 3:10 am
Location: BumbleF&%K, NJ
Contact:

Re: Class problem

Post by ircmaxell » Wed Nov 21, 2007 3:55 pm

Well, you need to load it.  Before the foreach loop, try adding this:

Code: Select all

jimport("joomla.html.html.select");
Joomla Development WorkGroup - Joomla BugSquad!
http://www.joomlaperformance.com For All Your Joomla Performance Needs
http://www.ircmaxell.com
The greatest obstacle to discovery is not ignorance, but the delusion of knowledge.

Muneo
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Fri Aug 19, 2005 3:02 am
Location: Brazil
Contact:

Re: Class problem

Post by Muneo » Wed Nov 21, 2007 4:40 pm

Thank you for your help, but I saw the JHTMLSelect's implementation and the return is object. I thought that this class print the option...

:(
Jorge Muneo Nakagawa
http://muneo.joanopolis.com.br

User avatar
ircmaxell
Joomla! Intern
Joomla! Intern
Posts: 52
Joined: Thu Nov 10, 2005 3:10 am
Location: BumbleF&%K, NJ
Contact:

Re: Class problem

Post by ircmaxell » Wed Nov 21, 2007 4:44 pm

What you do, is something like this

Code: Select all

foreach ($weblinks as $link) {
$options[] = JHTMLselect::option($link->url, $link->url);
}

$html = JHTMLselect::genericlist($options, "name_to_use");
echo $html;


where name_to_use is the name of the select tag...
Joomla Development WorkGroup - Joomla BugSquad!
http://www.joomlaperformance.com For All Your Joomla Performance Needs
http://www.ircmaxell.com
The greatest obstacle to discovery is not ignorance, but the delusion of knowledge.

Muneo
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Fri Aug 19, 2005 3:02 am
Location: Brazil
Contact:

Re: Class problem

Post by Muneo » Wed Nov 21, 2007 5:58 pm

Simply perfect...
Thanks a lot!!!  :)
Jorge Muneo Nakagawa
http://muneo.joanopolis.com.br

User avatar
ircmaxell
Joomla! Intern
Joomla! Intern
Posts: 52
Joined: Thu Nov 10, 2005 3:10 am
Location: BumbleF&%K, NJ
Contact:

Re: Class problem

Post by ircmaxell » Wed Nov 21, 2007 6:02 pm

Now, the question is, do you see why that works?

Take a look at /libraries/joomla/html/html/select.php... 
Joomla Development WorkGroup - Joomla BugSquad!
http://www.joomlaperformance.com For All Your Joomla Performance Needs
http://www.ircmaxell.com
The greatest obstacle to discovery is not ignorance, but the delusion of knowledge.

Muneo
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Fri Aug 19, 2005 3:02 am
Location: Brazil
Contact:

Re: Class problem

Post by Muneo » Wed Nov 21, 2007 6:09 pm

Yes!  ;)
Your solution is construct the array with options firstly and after mount the select (that return html code) and print with echo...

My module is using that now... http://muneo.joanopolis.com.br/index.php?option=com_content&view=article&id=49:Weblinks%20Suite%201.0&catid=35:M%C3%B3dulo&Itemid=57
Last edited by Muneo on Wed Nov 21, 2007 8:47 pm, edited 1 time in total.
Jorge Muneo Nakagawa
http://muneo.joanopolis.com.br

User avatar
ircmaxell
Joomla! Intern
Joomla! Intern
Posts: 52
Joined: Thu Nov 10, 2005 3:10 am
Location: BumbleF&%K, NJ
Contact:

Re: Class problem

Post by ircmaxell » Wed Nov 21, 2007 6:10 pm

Glad to hear it!
Joomla Development WorkGroup - Joomla BugSquad!
http://www.joomlaperformance.com For All Your Joomla Performance Needs
http://www.ircmaxell.com
The greatest obstacle to discovery is not ignorance, but the delusion of knowledge.


Post Reply