Customizing Dojo Widgets - customization

How do I customize an existing Dojo widget? I'm using dojo version 1.3. In the previous versions we had the html file under templates folder. Do I need to edit the source code directly.
I need to add an image to Accordion widget. Can someone please help me in customizing it?
Thanks in advance.

First, grab the existing template from the dojo library. This'll be your starting point.
Then, create your own widget that inherits from AccordionContainer, but specify your own html template:
dojo.declare("MyWidgets.Accordion", dijit.layout.AccordionContainer, {
templatePath: dojo.moduleUrl("MyWidgets","Accordion.html");
});
(dojo.moduleUrl is a nice way of specifying folder paths so the dojo library can find and inline them when you package up your final product).
This way, you leave the original source intact, but can set your own html and override any methods as needed.

That HTML template is still there in the templates folders. You just need to download the source release. Depending on your needs you could 1) set the content by adding children, 2) write custom widget inheriting it or 3) use it as a part of compound widget. Inheritance in Dojo way is simple:
dojo.declare("my.Accordion", dijit.layout.AccordionContainer, {
// your methods...
});

I think you could extend the existing widget rather than modifying it.

Related

can gtkmm change the css property of a class programmatically?

Gtk::StyleContext has methods for adding and removing a CSS class. Can I change the property of this class programmatically?
Yes, sort of; you can load another CSS file in the style context's CSS provider, that has different rules for that CSS class.
I suspect you might be asking about how to go into the rules directly and edit them programmatically; you can't do that.

Can we restrict a Sitecore item to have only one header and footer renderings?

I am using Sitecore 8.2 and I have many items, created from the same template. Though I have set the renderings in the standard value of the template for common components like header and footer, but want to make sure that these renderings can't be added twice.
Can we achieve this? If yes, what the ways?
If you do not make the rendering available to be added to a placeholder, then no author will be able to select it from the Component selection dialog in Experience Editor.
The "Allowed Controls" list is how you will specify which controls are allowed to be added to a given placeholder.
If you mean you want authors to not add the rendering twice, then probably you can add a processor into < insertRenderings > pipeline. Check if that helps.

Customize single-product template

I created my own template named ibtheme, then I copy woocommerce folder from Woocommerce plugin to my template. But when I click on a product on frontpage, I see that it call the template files in plugins/woocommerce/templates/single-product, not from ibtheme/woocommerce/templates/single-product/
Please help me to override product page template!
Thanks advance!
As you have already discovered, you can edit the template files in an upgrade safe way through overrides. Simply copy it into a directory within your theme named /woocommerce, keeping the same file structure.
Example: To overide the price display template, copy: wp-content/plugins/woocommerce/templates/single-product/price.php to wp-content/themes/ibtheme/woocommerce/single-product/price.php
You can read the full documentation for WooCommerce theming at Template Structure + overriding templates via a theme
I would suggest that only copy/override the specific templates that you plan to modify. I've had to go through every single template to repair a broken theme/site after a major WooCommerce upgrade, so trust me, this will make it easier to upgrade WooCommerce in the future.

Joomla 3 Template override a plugin

I could not find any info on overriding a Joomla plugin in my template.
Some forums claimed there was no plugin override, and the Joomla documentation (being the menacing forest that it is) either has nothing on the subject, or the page is hard to find.
So how can we override the output of a Joomla plugin in the same was we override the output of com_content or mod_contact?
I have found a way to do this:
Navigate to <joomla_homefolder>/administrator/language/<your_language>/
Search for the plugin's corresponding language file.
Copy the file name, EXCLUDING the language prefix (ie en-GB.) and the .ini suffix.
In your template create a folder named html (a common practice for template overrides).
In the html folder create a subfolder and name with the language file name as you copied it in step 3.
Navigate to the tmpl subfolder in the plugin's path: <joomla_homefolder>/plugins/<plugin_type>/<plugin_name>/tmpl
Copy the view file you wish to override into the folder you've created in step 5.
Modify the copied file to override the plugins output.
For example -
To change the page navigation buttons - modify the output of <joomla_homefolder>/plugins/content/pagenavigation:
Go into <joomla_homefolder>/administrator/language/en-GB/ and find the file named en-GB.plg_content_pagenavigation.ini.
From the filename copy only plg_content_pagenavigation.
Create a folder named html (If it does not exist already) in your theme, inside it create a subfolder and name it plg_content_pagenavigation.
Copy the view file <joomla_homefolder>/plugins/content/pagenavigation/tmpl/default.php into the plg_content_pagenavigation folder you just created.
Modify the file.
Note: I have tried it only with Joomla 3.1.
The method may not work with some plugins.
Good Luck.
In joomla 3 you can override plugins output only, that's why the origin plugin must be implemented with a tmpl.
The naming convention of the folder in you [template]/html is
plg_[type*]_[pluginElement]
Template overridden native joomla plugins is only the pagenavigation.
type* : obviously there's no sense to be other than content but if it's custom plugin no one can stop you.
On a Joomla 3.1 install, I am using the Simple Image Gallery plugin and I felt the need to override it in order to add extra functionality to each thumbnail of the gallery.
I copied all of the contents of <joomla_homefolder>/plugins/content/jw_sig/jw_sig/tmpl/ into the folder <joomla_homefolder>/templates/protostar/html/jw_sig/ and I was then able to modify both the default.php file for output modifications, and the accompanying template.css file for styling modifications. This successfully overrides the plugin's output without risking issues during future updates.
Of course, this will not work with all plugins, but it offers another alternative if you have a plugin that was nice enough to be developed with a tmpl folder.
No you can't override the same way because there is not tmpl folder because plugins really should not be rendering though of course a lot do. You probably need to clone the plugin and make a the layout your want possibly using a jlayout to make it easier to manage.
Elin's answer is not quite correct for Joomla 2.5-3.x. Some plugins do render screen output and have /tmpl folders that you may be able to override. See http://docs.joomla.org/Layout_Overrides_in_Joomla
In some cases you may need to create alternative views within the plugin /tmpl folder. For example, some of the simple, newer custom content components that use JForms let you add fields to com_content articles and select a view template for each field. Then overrides for com_content are generated dynamically to display the custom fields. Each field type can be displayed in the component area through plugins, or in a module, or within the template code, but it will use the /tmpl file you selected for the field in the CCK component. If there is a way to override the different field views from within the template folder, it must require an arcane menu structure I haven't been able to discover.

Overriding templates when using Grappelli

I'm using Grappelli with Django. When I follow the procedure as outlined in the Django docs to override a specific template for a specific model, it appears that Django (or Grappelli??) are struggling to render the template correctly.
I have copied the change_form.html file to the templates directory with the following subpath:
admin/properties/Calendar
where properties is the name of the app and Calendar is the name of the model for which I want to override the change form. Now the following appears
At least two things are not rendered correctly:
The breadcrumb bar is much thinner and the crumbs are tightly aligned with the left border of the bar.
The link for the history of changes is in the wrong place (it appears on the left), has the wrong style (no rounded edges) and appears twice.
I double checked that the correct template file is used by Django, so the mechanism as documented works albeit with the above described flaws. When I rename the duplicated template file or delete it from my app, everything looks fine again.
Before I dive into this, I was hoping someone could hint at what is going wrong here. All not overridden templates seem to work just fine.
From what I read I suspect you copy the default admin change_form.html template and not the grapelli version, found at grappelli/templates/admin/change_form.html.
If you want to override a grapelli template, then you should use that as source!