Your SlideShare is downloading. ×
Template Layout Overrides - a beginner's guide
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Template Layout Overrides - a beginner's guide

9,246

Published on

Template overrides are now being very widely used in some of the better produced templates, but do you really understand how they work? Have you got a clue what the MVC concept is all about? We had …

Template overrides are now being very widely used in some of the better produced templates, but do you really understand how they work? Have you got a clue what the MVC concept is all about? We had to do a bit of research ourselves to be able to explain it to others in "non geek speak" - hopefully you'll find this presentation useful.

Please note that there was a lot of discussion relating to this presentation - why not come along to our Joomla! User Group meeting to find out what you're missing!

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
9,246
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
159
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Template overrides and the “MVC” concept Ruth Cheesley Suffolk Computer Services [email_address]
  • 2. WHAT IS MVC?
  • 3. What is MVC?
    • M ODEL
      • Manages the behaviour and the data
    • V IEW
      • Manages the graphical and/or textual output
        • Article, Category Blog, Section list
    • C ONTROLLER
      • Interprets mouse/keyboard inputs
  • 4. Request for a section blog layout content page is sent (by user browsing to the page) Controller analyses the request and passes to appropriate component (com_content) Appropriate data (from the section ID) is pulled from the database and passed to the view View (section) and layout (blog) applied, overrides applied, content is displayed to user
  • 5. WHY USE TEMPLATE OVERRIDES?
  • 6. Why use Template Overrides?
    • Avoid editing the core
    • Change how an extension is displayed
    • Greater flexibility
    • If Component/module is 1.5 Native & uses MVC structure (has views/tmpl folder)
  • 7. TEMPLATES, VIEWS AND LAYOUTS
  • 8. Views and Layouts
    • Components display information in different ways (“views”)
    • Most components will have many views
      • com_content
        • Single article
        • Category/Section
        • Archive
        • Front Page
    • The view does not display the output – this is done by a “layout” (e.g. blog, html, RSS feed, PDF)
  • 9. Run that by me again?!
    • Components can have multiple views
      • Each view assembles a fixed set of information (e.g. The Category view in Articles component assembles a number of articles)
    • Each view can have multiple layouts
      • Each layout can display the information in different ways (e.g. The Category view in Articles component can be laid out in blog or list layout)
  • 10. What about modules?
    • Generally only display one thing, one way
    • Don’t really have views, but do support a layout
  • 11. Templates and Layouts
    • Templates set up a structural framework for the page of the website
      • Positions for modules & components to display
    • What gets displayed is controlled by
      • Module layout
      • Combination of view & layout in the case of a component
  • 12. Typical layout (rhuk_milkyway) Append ?tp=1 to show module positions over your template E.G. index.php?tp=1
  • 13. Component Structure
    • Components/  High level folder (contains all components)
    • com_content/  Individual component folder
    • views/  The different views available for that specific component
    • articles/  For when displaying a single article view.html.php (this is the view that outputs the html)
    • view.pdf.php (this is the view that outputs the PDF)
    • tmpl/  Template folder
      • default.php (this is a layout)
      • form.php (this is a layout)
    • category/  For when displaying articles in category view
    • view.html.php (this is the view that outputs the html)
    • view.feed.php (this is the view that outputs RSS feed )
    • tmpl/  Template folder
    • blog.php (this is a layout)
    • blog_items.php (this is a sub-layout)
    • default.php (this is a layout)
  • 14. HOW TO OVERRIDE
  • 15. How to override components?
    • Templates/  High level folder (contains all templates)
    • MyTemplate/  My Template folder
    • html/  The template overrides folder
    • com_content /  The component to be overridden
    • articles/  Overrides to apply to single article view
      • default.php (this is a layout)
      • form.php (this is a layout)
    • category/  Overrides to apply to category view
    • blog.php (this is a layout)
    • blog_items.php (this is a sub-layout)
    • default.php (this is a layout)
    • Note:
    • There are three other views for com_content:
    • Archive
    • Section
    • Frontpage
    • It is not possible to customise the PDF or RSS feeds currently
  • 16. How to override components?
    • Copy / components / com_content / views / article / tmpl /default.php
    • To
    • / templates / rhuk_milkyway / html/com_content / article /default.php
    • Make changes to file in template folder (not in the core)
    • Joomla will check for overrides – if there’s a file in the html folder for this component and this view, use it. Else, use default file .
  • 17. What about modules?
    • Modules/  High level folder (contains all modules)
    • mod_latestnews/  Individual module folder
    • helper.php (helper file containing data logic)
    • mod_latest_news.php (main module file)
    • mod_latest_news.xml (module installation XML file)
    • tmpl/  The templates for that module (usually only one, but can be more)
    • default.php (this is a layout)
  • 18. How to override modules?
    • Copy
    • / modules / mod_latestnews / tmpl /default.php
    • To
    • / templates / rhuk_milkyway / html/mod_latestnews /default.php
    • Make changes to file in template folder (not the core)
  • 19. What else can I override?
    • Module Chrome
    • Pagination
    • Check out http://docs.joomla.org/Understanding_Output_Overrides
    • for some examples
  • 20. THINGS TO CONSIDER
  • 21. Things to consider
    • Only override 1.5 NATIVE MVC enabled components/modules (with views/tmpl folder)
    • Can’t override PDF/RSS Feeds (you have to edit the core)
    • File path is essential – get it right!
  • 22. Ruth Cheesley Suffolk Computer Services [email_address]
  • 23. References
    • Joomla Docs:
    • http://docs.joomla.org/MVC
    • http://docs.joomla.org/Understanding_Output_Overrides
    • http://docs.joomla.org/Category:Templates
    • http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core
    • Wikipedia:
    • http://en.wikipedia.org/wiki/Model-view-controller

×