May The Core Be With You
About this talk
Why Use More Core?
Easier Upgrades
Extension Compatibility
Knowledge Transfer
Future Proof
How To:
Make The Most Out of Core
Example 1:
Carousel With Modules
Order of Operations
1. Add chrome to modules.php
2. Add position to template index.php
3. Add new custom module layout
4. ...
function modChrome_carouselInner($module, &$params,
$attribs)
{
$img = $params->get('backgroundimage');
$sfx = htmlspecial...
<?php if ($this->countModules('carousel')): ?>
<div id="bootstrap-carousel" class="carousel slide">
<div class="carousel-i...
<?php echo $module->content; ?>
mod_custom new layout
Sanity Check
File Locations
Template Index File (new module positon):
<jroot>/templates/my_template/index.php
Modules.php ...
Position: carousel
Content: description text
Div Class: active (first slide/module)
Title: slide title
Background Image: Slide Image
Select new alternate layout
Results
Example 2:
Alternate Category Layout
Order of Operations
1. Copy some view files to the template
2. Make some minor code changes
a. this is an ‘alternate layou...
Copy view files to template
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout
title="COM_CONTENT_CATEGORY_VIEW_BLOG_TITLE"
option="COM_CONTENT...
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout
title="COM_CONTENT_CATEGORY_VIEW_ACCORDION_TITLE"
option="COM_CO...
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle"
data-toggle="collapse"
data-pare...
Let’s just recap
500+ Extensions!?
(Or we could just use core…)
Example 3:
Language Manager ‘Hack’
<?php // some view, or model, or controller, or anything ?>
<?php echo JText::_('GLOBAL_CONSTANT'); ?>
<?php // the rest o...
What’s next?
Bloated CMS
Improve the CMS
Be Creative
Thanks!
“Fear is the path to the Dark Side. Fear leads to anger, anger
leads to hate, hate leads to suffering.”
- Yoda
Better Unde...
May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014
Upcoming SlideShare
Loading in …5
×

May the core be with you - JandBeyond 2014

418 views

Published on

Slides from Chad Windnagle's talk at JandBeyond 14.

Full description:
Joomla has some amazing and powerful technology that can make using it for highly customized sites very easy. Learn how to embrace the Joomla core, stop using extensions for simple things that Joomla can already do, and make upgrading or migrating your sites much easier. This session will demonstrate to attendees the methods used to customize Joomla in simple ways that have a big impact on building sites that make the most out of core as possible.

Specific techniques that will be demonstrated:
-Language Overrides
-Template Overrides
-Module Chromes

http://jandbeyond.org/program/sessions/may-the-core-be-with-you.html

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
418
On SlideShare
0
From Embeds
0
Number of Embeds
20
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • I wanted to do a talk about using the Joomla core as much as possible. I believe this is a trend in the community right now and a very good one. It’s a little strange to talk about because in general, the whole point of using a CMS like Joomla is that its expandable and there’s tons of extensions available for it. So this is a bit counter culture to that idea. But to me its important to know, explore and push the limits of the core CMS as much as possible.

    We know that the CMS is powerful, and I think in a perfect world we’ll have a core that can cover most user’s and developers most primal needs for technology. If we are a little more resistant to just installing extensions to solve problems, but instead investigate ways to push the limits of the core a bit further, I believe we will end up with a CMS that is more powerful, more functional, and able to meet more needs. Of course, we don’t want to make a large core, we just want to make a flexible one. So the intent here has to be a balance between function and flexibility versus slim core and powerful distribution.

    Distributions may come along and help solve a lot of these problems - fingers crossed - but for now this is where we are at so that’s what I’m focused on.

    So I knew with a title like may the core be with you, some people were really expecting or hoping we would see a title slide a lot more like this!
  • So with that title slide out of the way - you can expect to see a few more photos that are going to play on the star wars themes. I hope there’s some fans!
  • So let me explain why I think using the core as much as possible is important. I already mentioned a little bit about what I think the results of this will be in the overall vision of this talk. But why should we do this?

    I believe that using the core as much as possible makes our lives easier as developers. There’s a few reasons for this.
  • The first is that updates and upgrades are just easier. If you know all your content is stored in com_content, you can feel reasonably certain that an update to Joomla isn’t going to break things for you. But if your content is stored in something like a 3rd party CCK, then you’ve immediately got more work on your hands. You need to check things like compatibility of the extension, the modules you might be using, and ensure that things will continue to run.
  • The end result of this extension compatibility issue can also be a security issue. Look at this example from Fabrik where users were told that they couldn’t update to a newer version of Joomla due to their compatibility. What if this had been a major security issue? Sites get hacked this way. There can be some pretty serious side effects from placing your life in the hands of other developers. Granted this is small case and probably not a big issue, but it can easily become one if you’re not careful.
  • The end result of this extension compatibility issue can also be a security issue.

    I know you can’t read this text, but it warns users of Joomla 3.2 to NOT update to Joomla 3.3 due to some compatibility issues. Now what if this had been a major security issue?

    Sites get hacked this way. There can be some pretty serious side effects from placing your life in the hands of other developers. Granted this is small case and probably not a big issue, but it can easily become one if you’re not careful.
  • Knowledge transfer. We host 200 websites, and we have some clients that have 3 or 4 sites with us. Imagine how much of a pain it would be if we had to train them on joomla content, and then a CCK, and then a blogging application, etc.. etc… It’s confusing. We had many clients log into Joomla and ask us where content was. It was there -- inside of K2, but not in com_content. This is highly confusing to users.

    We have a small staff as well but we’re all able to pretty much move between sites we’re concurrently developing without ever being on the site before because we’re consistent in how we build this.

    But overall if you can be confident that you’ve built sites consistently, when you log into them you’ll know where everything is, and so will people who’ve never been in the system before who are just starting out. Consistency will make your life better and you’ll be able to switch between the sites you’re working on if you do everything the same all the time.
  • Future proof. The Joomla 1.5 to 1.6 migrations and on should be a good lesson to everyone that migrations can be expensive, time consuming pains in the rear! The lesson we learned was that core content is in general easy to migrate. Migrating other extensions and their data was a pain. This is because the user base of those other extensions was small, the number of users testing the code and doing the migrations was far less, and so bugs and other issues were rampant. If you stick to core you’re almost certain to have more than one case of migration issues, and that means solutions and resolutions for your issues.
  • Everything in moderation

    I don’t want to paint the picture that 3rd party extensions should be entirely avoided. We still use some here. But I can most certainly say that we spend more time with those sites. Now we selected other solutions for important reasons, and we knew that the ongoing work was going to be more effort, but it was necessary to get the job done as best as possible. So use third party solutions when it’s necessary, but think about the long term effects of this - give yourself an out!
  • Alright so now that we’ve established the basic ideas that we probably should try to use the core as much as possible. At this point I can come down off my soapbox and actually paint a picture of how we can use core to the best of our abilities.

    Its time to learn how to make the most out of the this powerful tool. Use the force,right?
  • I’ve put together a few examples of how we can do some ‘every’ tasks that we often go outside of Joomla to implement. I hope you find these solutions useful to you and you’ll use them as a way to be creative and come up with your own implementations.


    I have some examples on different ways to use the core. Keep in mind, these are examples. They’re intended really to provoke your curiousity and help you think about exploring some similar solutions for your own projects.
  • Alright so my first example is pretty simple. We’re going to create a carousel using custom html modules. This requires some custom code in our template but that’s it!
  • So I wanted to just do a quick overview of the steps we’re going to be taking here. First we’re going to add a bit of custom code to two places, pretty simple stuff, then we will create a new layout file. After that we can add our module positions and check the result.
  • Use the module manager to create custom html modules. Put the description text in the text area, use the background image field to specify the image location. use a custom position (eg carousel) for use in the template later on.
  • Use the module manager to create custom html modules. Put the description text in the text area, use the background image field to specify the image location. use a custom position (eg carousel) for use in the template later on.
  • What we’re going to do here is create a new custom layout in the template by creating a new layout file. The default layout file is called default.php. We’ll create a new one called text.php. The contents of this file will be pretty basic. We’re just going to print out the pure content from the module. We don’t want any of the extra html as that will just get in the way in this case.
  • So before we go any further I just want to give everyone a quick review of where the files are located here just incase this wasn’t obvious! We’ve worked with 3 files at this point. The template’s main markup file, the modules.php file which is for creating and adding custom markup to module output, and then created a new layout file for the custom html module.

    So hopefully everyone is on the right page here.

    Let’s go to the next step of this process and add some new modules to our site.
  • Use the module manager to create custom html modules. Put the description text in the text area, use the background image field to specify the image location. use a custom position (eg carousel) for use in the template later on.
  • Use the module manager to create custom html modules. Put the description text in the text area, use the background image field to specify the image location. use a custom position (eg carousel) for use in the template later on.
  • Use the module manager to create custom html modules. Put the description text in the text area, use the background image field to specify the image location. use a custom position (eg carousel) for use in the template later on.
  • Alright so my first example is pretty simple. We’re going to create a carousel using custom html modules. This requires some custom code in our template but that’s it!
  • Alright so my first example is pretty simple. We’re going to create a carousel using custom html modules. This requires some custom code in our template but that’s it!
  • So here’s another overview for the set up. This is a bit more code heavy than the last one but its pretty useful tool. Let’s see what we can do here!
  • This is a screenshot of the files we’re going to end up working with. We have the view files for com_content, and we’re going to copy them over to our template, and then rename them.
  • Here’s the default blog xml. The .xml is parsed by the menu manager to create menu types. We’re going to rename it from blog to accordion, and we’ll change some of the language strings so it shows up differently in the menu manager. Let’s see what we change.
  • You can see here all I did was change the name and the language string. If you want to get really detailed you could change the description and some other areas too to add custom language strings. Not necessary for the examples we’re going to be doing but useful for production sites.
  • What I’ve done is really modified the view file so that it outputs some bootstrap markup. As you should be able pick up by now we are creating an accordion out of boostrap code. This markup will be the what Bootstrap automatically loads and looks for to generate accordions.

    It sets up the accordion group and pulls the category id for a proper data parent, and then uses the article title for the accordion selector, and the content as the accordion body.
  • Alright so we’ve got two working examples now. Let’s recap and see what we’ve got going on here.
  • So this image shows us that there are 100 rotator extensions for Joomla, and an astounding 420 extensions for slideshows.
  • So we could install one of those 500+ extensions...or we could just use the core. That’s amazing I think!
  • Alright so my first example is pretty simple. We’re going to create a carousel using custom html modules. This requires some custom code in our template but that’s it!
  • Use the module manager to create custom html modules. Put the description text in the text area, use the background image field to specify the image location. use a custom position (eg carousel) for use in the template later on.
  • Okay - so this is the end of what I really wanted to demonstrate to you. But it’s not the end of what I want to talk about. There’s just a few more things I want to say about this topic. And that is, I want to talk about improving the CMS a bit, and the kind of attitude I believe we developers should have towards the CMS.

    The CMS is wonderful, and I think there’s a lot of benefit to having a CMS that can do EVERYTHING out of the box. Right - it would be great for so many users.
  • But the big problem of course is that we would end up with this hugely bloated piece of code which is just a pain to work with. So the answer is not to just make the CMS do everything that an extension does. There is a time and place for extensions. But hopefully we can collaborate around the idea
  • But the big problem of course is that we would end up with this hugely bloated piece of code which is just a pain to work with. So the answer is not to just make the CMS do everything that an extension does. There is a time and place for extensions. But hopefully we can collaborate around the idea that we should be improving the CMS.
  • So we want to avoid the Jabba The Bloated Hutt problem. But if there are improvements that can be made to the core that actually BELONG in core, then we should be making that core code better as long as it’s possible and meets our other core-level coding requirements. The end result here is to improve as much as possible what we have, which overall should enable us to continue making the core as useful for as many people as possible. Again, we want to make things better but not necessarily throw in the kitchen sink here.
  • The overall point that I’m trying to get across is to think outside the box, be creative with how you use Joomla and find ways to use it that save you time, save you effort, and make it easier for your clients to manage their website.

    As you approach a project and you’re able to use core do it. If you run into an issue where just some minor changes to the core could make a project go from a third party extension to using pure core, see if you can’t make that change happen. It’ll make the CMS better for all of us using it and you’ll be so much happier when doing an update to that site you were able to use that updater button!
  • So thank you everyone for your time - I hope you learned some things!

    Final slide -
  • May the core be with you - JandBeyond 2014

    1. 1. May The Core Be With You
    2. 2. About this talk
    3. 3. Why Use More Core?
    4. 4. Easier Upgrades
    5. 5. Extension Compatibility
    6. 6. Knowledge Transfer
    7. 7. Future Proof
    8. 8. How To: Make The Most Out of Core
    9. 9. Example 1: Carousel With Modules
    10. 10. Order of Operations 1. Add chrome to modules.php 2. Add position to template index.php 3. Add new custom module layout 4. Add module instances to position 5. Check the result
    11. 11. function modChrome_carouselInner($module, &$params, $attribs) { $img = $params->get('backgroundimage'); $sfx = htmlspecialchars($params- >get('moduleclass_sfx')); if ($module->content) { echo "<div class="item" . $sfx . "">"; echo "<img src="" . $img . "" >"; echo "<div class="carousel-caption">"; echo $module->content; echo "</div>"; echo "</div>"; } } modules.php
    12. 12. <?php if ($this->countModules('carousel')): ?> <div id="bootstrap-carousel" class="carousel slide"> <div class="carousel-inner"> <jdoc:include type="modules" name="carousel" style="carouselInner" /> </div> <a class="carousel-control left" href="#bootstrap-carousel" data-slide="prev"> &lsaquo; </a> <a class="carousel-control right" href="#bootstrap-carousel" data-slide="next"> &rsaquo; </a> </div> <?php endif; ?> template’s index.php
    13. 13. <?php echo $module->content; ?> mod_custom new layout
    14. 14. Sanity Check File Locations Template Index File (new module positon): <jroot>/templates/my_template/index.php Modules.php File (new module chrome): <jroot>/templates/my_template/html/modules.php Custom Module Layout (for mod_custom): <jroot>/templates/my_template/html/mod_custom/text.php
    15. 15. Position: carousel Content: description text Div Class: active (first slide/module) Title: slide title
    16. 16. Background Image: Slide Image
    17. 17. Select new alternate layout
    18. 18. Results
    19. 19. Example 2: Alternate Category Layout
    20. 20. Order of Operations 1. Copy some view files to the template 2. Make some minor code changes a. this is an ‘alternate layout’ 3. Add new menu item 4. Check the result
    21. 21. Copy view files to template
    22. 22. <?xml version="1.0" encoding="utf-8"?> <metadata> <layout title="COM_CONTENT_CATEGORY_VIEW_BLOG_TITLE" option="COM_CONTENT_CATEGORY_VIEW_BLOG_OPTION"> <help key = "JHELP_MENUS_MENU_ITEM_ARTICLE_CATEGORY_BLOG" /> <message> <![CDATA[COM_CONTENT_CATEGORY_VIEW_BLOG_ DESC]]> </message> </layout> blog.xml
    23. 23. <?xml version="1.0" encoding="utf-8"?> <metadata> <layout title="COM_CONTENT_CATEGORY_VIEW_ACCORDION_TITLE" option="COM_CONTENT_CATEGORY_VIEW_ACCORDION_OPTIO N"> <help key = "JHELP_MENUS_MENU_ITEM_ARTICLE_CATEGORY_BLOG" /> <message> <![CDATA[COM_CONTENT_CATEGORY_VIEW_BLOG_ DESC]]> </message> </layout> accordion.xml
    24. 24. <div class="accordion-group"> <div class="accordion-heading"> <a class="accordion-toggle" data-toggle="collapse" data-parent="#cat-accord-<?php echo $this->item->catid; ?>" href="#accordion-<?php echo $this->item- >id; ?>"> <?php echo $this->item->title; ?> </a> </div> <div id="accordion-<?php echo $this->item->id; ?>" class="accordion-body collapse"> <?php // the content ?> </div> </div> accordion_item.php
    25. 25. Let’s just recap
    26. 26. 500+ Extensions!? (Or we could just use core…)
    27. 27. Example 3: Language Manager ‘Hack’
    28. 28. <?php // some view, or model, or controller, or anything ?> <?php echo JText::_('GLOBAL_CONSTANT'); ?> <?php // the rest of your code ?> Any Code in Joomla!
    29. 29. What’s next?
    30. 30. Bloated CMS
    31. 31. Improve the CMS
    32. 32. Be Creative
    33. 33. Thanks!
    34. 34. “Fear is the path to the Dark Side. Fear leads to anger, anger leads to hate, hate leads to suffering.” - Yoda Better Understood as: “Extensions are the path to the dark side. Extensions lead to migration problems, swearing and suffering.” - Unknown

    ×