parameters... what a pain

15 views
Skip to first unread message

Samuel Thurston

unread,
Nov 8, 2009, 1:51:52 PM11/8/09
to Joomla! General Development
Hello,

I'm currently writing a component that doesn't need its own database
table per se, because there are only three html areas that are admin-
configurable.

The joomla parameter system is a colossal mess. I have read this wiki
article about 3 times:

http://docs.joomla.org/Component_parameters

and I still feel like I have only a vague grasp of what should be a
fairly simple mechanism.

I'm pretty certain what I am looking to do is the component-wide
parameters method, where the html contents will be stored in
config.xml. However, in the list of standard parameter types, there
is a textarea, but no way to place a WYSIWYG editor control. This is
bad.

So is there a way to extend the core within a component to allow a
custom, html-aware parameter type? Will storing html in the
config.xml break the parsing? Or should I try using JParameter to
access the config.xml directly and bypass the built-in mechanism
altogether?

Any advice will be appreciated.

Paddy O'Brien

unread,
Nov 8, 2009, 3:37:59 PM11/8/09
to joomla-de...@googlegroups.com
It seems to me that you shouldn't be putting anything that requires a
WYSIWYG editor in a configuration file.

Are you not mixing content with configuration by doing that? A
database table seems like a more appropriate place for this sort of
data.

Paddy

Samuel Thurston

unread,
Nov 8, 2009, 9:48:30 PM11/8/09
to Joomla! General Development
On 8 Nov, 14:37, "Paddy O'Brien" <paddysem...@gmail.com> wrote:
> It seems to me that you shouldn't be putting anything that requires a
> WYSIWYG editor in a configuration file.

Well this is a slight beef I've had with joomla for some time.

basically the component consists of 1) a form and 2) a response to
that form. The client has asked for html content (that is to say the
ability to embed images and formatting into the text) before and after
the form, and on the response page.

>
> Are you not mixing content with configuration by doing that? A
> database table seems like a more appropriate place for this sort of
> data.
>

Is a database table that has three rows that consist of nothing but id
and content somehow not overkill for this feature? There are plenty
of components, even stock ones, that allow for a text area in places
like this which can be very long and involved, and into which a user
can (and often does) type html.

These aren't pages that will be accessed by direct link or something
like that, they're just small spots on a larger component page that
should be able to embed images and stuff without the user having to be
html-savvy. I strongly dislike the hackish "pick an image from this
drop-down" method, especially since several images may be called for
in some instances, and flash may be needed as well.

I guess I fail to see how 1000 or so characters of basic html differs
so fundamentally from a similar amount of plain-text.

As it stands, with my timeframe and the current state of my thinking,
a database table is probably exactly where this content will end up
for lack of anything else to do with it, but I'm really not happy with
this solution.

Thanks for your input though.

Amy Stephen

unread,
Nov 8, 2009, 10:27:19 PM11/8/09
to joomla-de...@googlegroups.com
Sam -

If you create a Joomla! Component, you can retrieve the Component Parameters anywhere in Joomla! using this syntax:

$params = &JComponentHelper::getParams( 'COMPONENT_NAME' );
$params->get( 'PARAMETER_NAME' );

From:
http://docs.joomla.org/Component_parameters#Accessing_the_parameters_-_frontend

Is that what you need?

I'm not following the comments on HTML input, very well. You should be able to input HTML into an Article (or a Custom Module), if you have your Filter parameters set to allow it.

http://docs.joomla.org/Why_does_some_HTML_get_removed_from_articles_in_version_1.5.8%3F

Sometimes, people use Custom Modules to add and position text, images, and multimedia content to an Article by also using the loadposition:

http://docs.joomla.org/How_do_you_put_a_module_inside_an_article%3F

Are those types of things helpful?

Cheers!
Amy

Samuel Thurston

unread,
Nov 9, 2009, 10:35:22 AM11/9/09
to Joomla! General Development
thanks for your comments Amy,

the filter parameters link is useful but not for what I'm asking
about.

Basically all I am looking to do is to add WYSIWYG editor capabilities
to a <textarea> parameter. For me it's no problem to just type html
into one of those boxes. For some clients however I might as well be
asking them to learn Latin.

So my question is: is there a way to add a new parameter type that
will put a WYSIWIG editor on the textarea without editing the core of
joomla... i.e. can this be extended in a component?

In the end I would write in my config.xml something like this:

<param type="html" name="greeting_area" label="Greeting:"
default="<h3>Hello</h3><p>Thank you for participating.</p>" />

I suppose the html in the default value would need to be encoded to be
xml compliant, but that's kind of beyond the scope of what I'm asking.

I notice that the parameter types are in /libraries/joomla/html/
parameter/element/ Could I write a class extending JElement and drop
it in here, or does it need to be triggered to load somewhere else?
Is there a way I could add the file within the scope of my component
so I don't have to try to drop it into the core directories?

On 8 Nov, 21:27, Amy Stephen <amystep...@gmail.com> wrote:
> Sam -
>
> If you create a Joomla! Component, you can retrieve the Component Parameters
> anywhere in Joomla! using this syntax:
>
> $params = &JComponentHelper::getParams( 'COMPONENT_NAME' );
> $params->get( 'PARAMETER_NAME' );
>
> From:http://docs.joomla.org/Component_parameters#Accessing_the_parameters_...
>
> Is that what you need?
>
> I'm not following the comments on HTML input, very well. You should be able
> to input HTML into an Article (or a Custom Module), if you have your Filter
> parameters set to allow it.
>
> http://docs.joomla.org/Why_does_some_HTML_get_removed_from_articles_i...
>
> Sometimes, people use Custom Modules to add and position text, images, and
> multimedia content to an Article by also using the loadposition:
>
> http://docs.joomla.org/How_do_you_put_a_module_inside_an_article%3F
>
> Are those types of things helpful?
>
> Cheers!
> Amy
>

Ian MacLennan

unread,
Nov 9, 2009, 10:54:25 AM11/9/09
to joomla-de...@googlegroups.com
No, filter parameters aren't at all what you're looking for.

If you wanted to try and create a custom WYSIWYG parameter type, you'd want to look at:
http://docs.joomla.org/Creating_custom_template_parameter_types

Those are for template parameters, but they really are the same.  You'll end up with something like
<params addpath=”[path]/elements”>

where path is the path to your directory containing your custom elements.

The other option is to use an article selection parameter so all your content gets created with the Article Manager and users just select an article to contain that text.  There are obviously pros and cons of this approach.

Anyway, hope that helps.
Ian

Christophe Demko

unread,
Nov 11, 2009, 10:17:27 AM11/11/09
to Joomla! General Development
In your component folder put a file elements/editor.php containing

<?php
defined('_JEXEC') or die('Restricted access');
class JElementEditor extends JElement {
/**
* Element name
*
* @access protected
* @var string
*/
var $_name = 'Editor';
function fetchElement($name, $value, &$node, $control_name) {
$rows = $node->attributes('rows');
if ($rows == '') $rows = 20;
$cols = $node->attributes('cols');
if ($cols == '') $colss = 60;
$width = $node->attributes('width');
if ($width == '') $width = '100%';
$height = $node->attributes('height');
if ($height == '') $height = '100%';
$buttons = $node->attributes('buttons');
if ($buttons == 'false') $buttons = false;
else $buttons = true;
$editor = & JFactory::getEditor();
return '<div style="text-align: left;">'.$editor->display
($control_name .'['. $name .']', $value, $width, $height, $cols,
$rows, $buttons).'</div>';
}
}

in your config.xml file

<params addpath="/administrator/components/*your component*/
elements">

<param
name="description"
type="editor"
default=""
label="DESCRIPTION"
description="ENTER A DESCRIPTION" />

Hoping it will help you

On 9 nov, 16:54, Ian MacLennan <ian.maclen...@joomla.org> wrote:
> No, filter parameters aren't at all what you're looking for.
>
> If you wanted to try and create a custom WYSIWYG parameter type, you'd want
> to look at:http://docs.joomla.org/Creating_custom_template_parameter_types
>
> Those are for template parameters, but they really are the same.  You'll end
> up with something like
> <params addpath=”[path]/elements”>
>
> where path is the path to your directory containing your custom elements.
>
> The other option is to use an article selection parameter so all your
> content gets created with the Article Manager and users just select an
> article to contain that text.  There are obviously pros and cons of this
> approach.
>
> Anyway, hope that helps.
> Ian
>

Amy Stephen

unread,
Nov 11, 2009, 12:42:57 PM11/11/09
to joomla-de...@googlegroups.com
Nice! Thanks, Christophe!

Also noticed you have been doing nice work http://docs.joomla.org/Category:Joomla%21_1.6

Much appreciated!

Samuel Thurston

unread,
Nov 11, 2009, 1:21:16 PM11/11/09
to Joomla! General Development

A most excellent example. Thank you.
Reply all
Reply to author
Forward
0 new messages