How to specify a numeric component parameter for article selection - joomla

In setting up the parameters for my component,I want one of them to be an article ID that is opened and used. According to Joomla Standard Parameter Types, text is the only option.
Can integers be specified, or is there a way to validate the input?

As far as I know, text is your only standard solution. Joomla does, however, allow for custom parameter types. You could conceivably do one for integers, but if it's only for article selection, you can do what Joomla does for the com_content component.
Create a new folder in your admin component called: administrator\components\com_mycomponent\elements
Copy administrator\components\com_content\elements\article.php to your new folder (and index.html for security)
You can now specify a parameter type of "article" in your component as shown below, and you'll have a dropdown of your articles in the component configuration.
Be sure to include addpath to your elements folder in your "params".
<params addpath="/administrator/components/com_mycomponent/elements" />
<param type="article" name="article_id" default="0" label="Select Article" />

Related

Web Forms For Marketers (WFFM) Rich Text Field Type

I need to create a custom field type in WFFM to accept rich text, and provide Sitecore's WYSIWYG editor for the user on the front-end. The form will be used to create a content item, and the rich text field will map to a field on that item's template. Has anyone done this? Can the Telerik editor be leveraged for this?
If you need a simple WYSISYG editor on the front-end, then you can use any of the numerous open source editors available on the web. I would be wary of using the Telerik editor included in Sitecore unless you have the relevant licenses.
If you use a Multi-Line Text field on the form, Sitecore outputs a regular <textarea> on the front-end. I suggest you add a custom css class under /sitecore/system/Modules/Web Forms for Marketers/Settings/Meta data/Css Classes and select that from the CSS Class drop on the left when you select your field in the form designer, in order to allow you to target specific fields to be WYSIYG'd.
Add a reference to the javascript file and then instantiate your editor, passing in the css class defined above to only target those specific textareas.
If you are using ASP.Net MVC and CKEditor (for example):
Add reference to javascript in /Views/Form/Index.cshtml. You may need to add this to your Visual Studio from the WFFM module package.
Or add the reference in <head>:
<script src="/path-to/ckeditor/ckeditor.js"></script>
Add the bottom of Index.cshtml (or just before your closing </body> tag), instantiate your editor, targeting only those <textarea> with specific css classes
e.g.
<!-- markup generated by WFFM -->
<textarea class="wffm-rte" data-val="true" data-val-length="..." data-val-required="..." id="wffm-generated" name="wffm-generated"></textarea>
<script>
// Replace all <textarea class="wffm-rte"> elements with CKEditor instances.
CKEDITOR.replaceAll('wffm-rte');
</script>
Be sure you sanitize your incoming data, you don't want a case of bobby tables.

Using variables in custom joomla module for tooltips

I'm new to joomla development, but I can't seem to figure out how to dynamically fetch descriptions to be displayed as tool tips for the form data of a module backend. I'm looking at an example module from joomlart and their code for a single field element in their xml file looks like this.
<field
name="mainWidth"
type="text"
default="auto"
size="5"
label="MAIN_WIDTH"
description="MAIN_WIDTH_DESC" />
MAIN_WIDTH and MAIN_WIDTH_DESC are obviously variables that are somehow being accessed and rendered later when the module is run in the backend but I can't find where the values to these variables are stored or how to replicate this behavior. Any help would be appreciated.
Label is the label that prints to screen, and description is rendered as the tooltip.
You can just replace these variable names with the actual text and it will work when the form is rendered.
However, in your example, I believe they are using language files to get the text to display.
Whilst you can set a language file within your module for that module's use, naming convention suggests to me that these are being pulled from somewhere like the template's language file.
( Such a file is likely to be found either under /language or /administrator/language or /templates/yourtemplate/language )
The benefit of such files is to allow for translations of the site to exist without having to write a new module / template each time.
Ultimately, if you don't want various language versions of your site, and you only intend to use the module on one site and not sell it as an extension, then there is no strong need to create a language file for your own bespoke modules (though best practise would probably be to do so).

Joomla - Where do {} brackets work?

Just a simple question - aside from articles, where do {} (replacement tags?) work on Joomla?
Actually, it depends on both the plug-in and the content type as to whether or not a replacement tags are acted on.
The first part is that the content type (component/modules) has to trigger the event type the plugin belongs to. Not all content types do it automatically, some for example have a setting per item (e.g. modules have a "Prepare Content" setting).
Finally, the plugin may test the content type and exclude itself from anything it doesn't recognise, or may only work on com_content i.e. standard Joomla articles.
These {} tags work in all content systems which parse text. So modules, articles and other content components which display text.

Internationalising with multiple views

I have an action called index that returns a view and I've defined 3 views: index.cshtml, index.fr.cshtml and index.sv.cshtml, each of which contains my page in a different language. I expected my app would automatically find these views and serve them according to the browser language preference set, but it doesn't seem to.
is there some switch I have to turn on to make this work? I did add <globalization uiCulture="auto" culture="auto" /> to the <system.web> section of my web.config
TIA - e
If you go down this road, make a view per language you will end up with a lot a views and DUPLICATE code. something you want to avoid. A better approuch is the use of resources.
You can decide how far you go with globalisation : javascript / urls / tekst. The key is to make use of resources and put the key value pair there. Please look at http://channel9.msdn.com/Events/aspConf/aspConf/How-To-Achieve-World-Ready-Domination-In-ASP-NET-MVC-4
The index.mode.cshtml is for browser display mode of the ViewEngine.
You have to create a custom ViewEngine for localization. Here is one for WebForm. Just modify it to your needs and inherit from RazorViewEngine instead of WebFormViewEngine.

Multilingual support for struts2 tooltips

I need to show the text in the tooltips as per the user langguage.
I am using
s:textfield name="userName" title="This is the name of the user"/
How do i pick up the text "This is the name of the user" from a property file based on locale.
Struts2 textfiled already have parameter namely tooltip.All you need to use struts2 build in mechanism to fetch tool tip as per user locale.
here is what you have to do
<s:textfield name="myTextFiled" key="field.key" tooltip="%{getText('field.tooltip')}"/>
Please refer to the official documents for more details.
textfield

Resources