Extending Community Polls Using Template Overrides

Community Polls allow you to extend the template without loosing the work you've done when upgrading the component. This feature is introduced in v1.5.21. Before moving forward, below are few facts about the template framework of Community Polls.
  • Community Polls uses jQuery framework for all Ajax and user interaction. The required jQuery and jQuery UI libraries will be loaded from the assets/scripts directory when the component is loaded.
  • Community Polls stores default template under components/com_communitypolls/templates. The default folder stores the default template and required files.
  • Community Polls has the mechanism to load your css and JavaScript  files automatically from the templates. You need not include your scipts or styles manually. All you need to do is to place the scripts and styles in appropriate directories which you will learn later in this article.
  • When extending the templates, you need to copy all resources from the template you are extending into your custom template. This includes images, scripts and styles etc.
  • The custom template location of Community Polls is JOOMLAROOT/templates/communitypolls/ .
  • An override to the default template's listing page is available as default2 template.
So here is the procedure to extend the default template that is part of the Community Polls package (components/com_communitypolls/templates/default)
  1. Copy the template directory "default" from the templates folder to the custom templates folder Do not rename the folder for now as you are extending the default template and want to keep the name as is.
  2. Keep the template files (*.php files) that you want to customize and remove all other .php files in your custom template folder. Below are the template files which you may be interested in:
    1. list.php - The home page of Community Polls. Displays polls listing.
    2. viewpoll.php - This page displays the individual poll
    3. viewpoll_grid.php - Displays grid polls
    4. newpoll.php - This page displays form for posting new poll
    5. userpolls.php - Displays polls submitted by user when "More from AUTHOR" link is clicked
    6. votedusers.php - Displays list of users who voted on currently viewing poll.
    7. polls_anywhere.php - Displays polls anywhere
  3. The Community Polls template system is intelligent enough to take the available template file from your custom template folder / selected template folder / default template folder. It looks for a template file in the sequential order of the following locations:
    1. JOOMLAROOT/templates/communitypolls/TEMPLATENAME folder where TEMPLATENAME is the name of your custom template (for now you can treat this as default as your custom template is extending from default template).
    2. components/com_communitypolls/templates/TEMPLATENAME folder
    3. components/com_communitypolls/templates/default folder
  4. Now if you want to customize only home page of Community Polls, just keep list.php file and remove other template files. Please note that you still need to keep all resources that you copied from default template
  5. Now customize the template file as you wish and Community Polls loads your template instantly.
Always use $this->escape($YOUR_STRING_VARIABLE) function when you are printing a string variable for security reasonsEx: echo $this->escape($row->title);
  • Friday, 09 July 2010

Random Poll

How many sites of you are using Community Polls extension?
Please vote or enter the answer if no option applicable to you.
Others, please enter here:
6810683 [{"id":"2468","title":"1","votes":"191","pct":"31.99","type":"x","order":"0","resources":[]},{"id":"2469","title":"2","votes":"106","pct":"17.76","type":"x","order":"0","resources":[]},{"id":"2470","title":"3","votes":"113","pct":"18.93","type":"x","order":"0","resources":[]},{"id":"2471","title":"4","votes":"84","pct":"14.07","type":"x","order":"0","resources":[]},{"id":"2472","title":"5","votes":"75","pct":"12.56","type":"x","order":"0","resources":[]}] ["#ff5b00","#4ac0f2","#b80028","#eef66c","#60bb22","#b96a9a","#62c2cc"] gpie 200 200 /demos/polls/vote/742-how-many-sites-of-you-are-using-community-polls-extension.html No answer selected. Please try again. Thank you for voting. Answers Votes ...

25% Off Coupon

Joomla runs best on HostGator. Get 25% off on your hosting bill at hostgator with coupon code COREJOOMLA25OFF.
Sign up now.

Newsletter

We do not spam your mailbox. Product updates/offers, security updates etc. will be sent.
captcha
Terms and Conditions