User Tools

Site Tools


documentation:create_first_theme

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
documentation:create_first_theme [2015/06/15 06:48]
mooeditor [Basic directory structure]
documentation:create_first_theme [2016/01/16 07:34] (current)
Line 13: Line 13:
 ===== How to create theme ===== ===== How to create theme =====
  
-Now lets go to **Admin**→**Home**** > Site Manager > Themes Manager > Create a New Theme** (See image) and fill the fields there shown. The only really important fields are the **name** and the **based on**, but it doesnt hurt to fill in the others too.+Now lets go to **Admin**→**Home**** > Site Manager > Themes Manager > Create a New Theme** ​ (See image) and fill the fields there shown. The only really important fields are the **name** ​ and the **based on**, but it doesnt hurt to fill in the others too.
  
 {{:​documentation:​f98758bbbfc0c89d3206da5b53849363.png}} {{:​documentation:​f98758bbbfc0c89d3206da5b53849363.png}}
Line 176: Line 176:
 By edit only files in your new theme, you are making sure that new versions that overwrite default css files will be updated without a problem (because you didn't edit those files), and those CSS changes (in the upgrade) will match new elements in the template files, then again if you're not using the default template the new rules wont affect anything By edit only files in your new theme, you are making sure that new versions that overwrite default css files will be updated without a problem (because you didn't edit those files), and those CSS changes (in the upgrade) will match new elements in the template files, then again if you're not using the default template the new rules wont affect anything
  
-  * **info.xml **  file is essential. Without it, your template won't be seen by Joomla!. The file holds key metadata about the template. +  * **info.xml **  file is essential. Without it, your template won't be seen by mooSocial!. The file holds key metadata about the template.
 <code xml> <code xml>
- 
 <?xml version="​1.0"​ encoding="​utf-8"?>​ <?xml version="​1.0"​ encoding="​utf-8"?>​
 <​info>​ <​info>​
Line 191: Line 189:
  
 </​code>​ </​code>​
 +
 +====== Making Layout Customization ======
 +
 +===== Customize Layout =====
 +
 +If you want to change the layout of the special page, there are 2 options:
 +
 +==== Option 1: Change layout in file ====
 +
 +You can copy this file from default to **View > Themed > Structure file**. Remember that you must keep the directory structure and the file name to get effect, for example if you want to custom ajax_share.ctp you must copy Activities directory also, so you will have Themed ⇒ <Your theme directory>​ ⇒ Activities ⇒ajax_share.ctp (see image)
 +
 +{{:​documentation:​9546eee075df176a8dfa2f4bcda21aa5.png}}
 +
 +**Example: **  To add the new text to the homepage, let go to **root/​app/​View/​Elements/​ajax **  then copy the home_activity**.ctp** ​ file and paste it to **root/​View/​Themed/​Mytheme/​Home/​ **
 +
 +{{:​documentation:​dc9dd0be2e09d8fe7d5a04d8106fb3e8.png}}
 +
 +{{:​documentation:​e8af5aeb5394d75b9b5d90531ef7e225.png}}
 +
 +<font 13.3333330154419px font-style: normal; font-variant:​ normal; font-weight:​ normal; letter-spacing:​ normal; line-height:​ 17.3333339691162px;​ orphans: auto; text-align: left; text-indent:​ 0px; text-transform:​ none; white-space:​ normal; widows: 1; word-spacing:​ 0px; -webkit-text-stroke-width:​ 0px; display: inline !important; float: none; background-color:​ rgb(255, 255, 255);/​Arial,​ Helvetica, FreeSans, sans-serif;;#​000000;;​rgb(0,​ 0, 0) font-family:​ Arial, Helvetica, FreeSans, sans-serif; font-size: 13.3333330154419px;​ font-style: normal; font-variant:​ normal; font-weight:​ normal; letter-spacing:​ normal; line-height:​ 17.3333339691162px;​ orphans: auto; text-align: left; text-indent:​ 0px; text-transform:​ none; white-space:​ normal; widows: 1; word-spacing:​ 0px; -webkit-text-stroke-width:​ 0px; display: inline !important; float: none; background-color:​ rgb(255, 255, 255);>​Lets open this file and add the below code to line 43</​font>​
 +
 +<font 13.3333330154419px font-style: normal; font-variant:​ normal; font-weight:​ normal; letter-spacing:​ normal; line-height:​ 17.3333339691162px;​ orphans: auto; text-align: left; text-indent:​ 0px; text-transform:​ none; white-space:​ normal; widows: 1; word-spacing:​ 0px; -webkit-text-stroke-width:​ 0px; display: inline !important; float: none; background-color:​ rgb(255, 255, 255);/​Arial,​ Helvetica, FreeSans, sans-serif;;#​000000;;​rgb(0,​ 0, 0) font-family:​ Arial, Helvetica, FreeSans, sans-serif; font-size: 13.3333330154419px;​ font-style: normal; font-variant:​ normal; font-weight:​ normal; letter-spacing:​ normal; line-height:​ 17.3333339691162px;​ orphans: auto; text-align: left; text-indent:​ 0px; text-transform:​ none; white-space:​ normal; widows: 1; word-spacing:​ 0px; -webkit-text-stroke-width:​ 0px; display: inline !important; float: none; background-color:​ rgb(255, 255, 255);>​*</​font>​
 +
 +<code php>
 +<div class="​welcome_text">​
 +<?php echo __("​Welcome to my site") ?>
 +</​div>​
 +
 +</​code>​
 +
 +Save it then refresh your site, you will see the text changed already.
 +
 +{{:​documentation:​87c4a40e45528af238b7a8c66f13c7dc.png}}
 +
 +==== Option 2: Change layout in Admin ====
 +
 +To customize the template file for custom theme, go to Admin > Themes Manager > mooSocial Base Theme, navigate to the view (template file) you want to modify ⇒ click Copy then select your theme. Click Proceed to make a copy of the template file in your theme folder (see image)
 +
 +{{:​documentation:​bc64278948213d08654c6d3eb8d6171d.png}}
 +
 +Now you can make changes to the file without affecting the base theme. Any changes made to the base theme will be overwritten when you upgrade the software.
 +
 +Changes in your custom theme will not be affected after upgrading. This means you don't have to redo your changes but if the base theme was changed in the new version, your custom theme will need to be updated (manually) as well.
 +
 +==== Custom layout general ====
 +
 +=== Head ===
 +
 +header.php - This file will contain the code for the header section of the theme; It includes all header blocks that were added at Admincp > Site Manager > Themes Manager > Layout Editor
 +
 +{{:​documentation:​f1412f1c778589e30724c1715dbfcdfc.png}}
 +
 +To add new block to header section, we can go to Admincp >
 +
 +Site Manager > Themes Manager > Layout Editor
 +
 +{{:​documentation:​3a186e965e748f88c354cd6db7affb47.png}}
 +
 +=== Body Section ===
 +
 +The main layout u se the Layout Editor to decide what content appears on specific pages or in your site-wide header and footer.
 +
 +It decides the overall layout by deciding how many columns you want to have on this page by clicking on the “Edit Columns” button.
 +
 +{{:​documentation:​bf7d45b2f2e53d9334dc5477406e0833.png}}
 +
 +Choose a template by clicking on the template that fits your page best. The horizontal blocks on the top and the bottom represent the Site Header page and the Site Footer page, which do not need to be displayed.
 +
 +{{:​documentation:​cc7f69a1dddad1854294d1471aff40a3.png}}
 +
 +=== Footer ===
 +
 +footer.php - This file will handle your footer. It includes all header blocks that were added at Admincp >
 +
 +Site Manager > Themes Manager > Layout Editor
 +
 +{{:​documentation:​5a89c49d9ea5b5d697ac9e14aa55e32f.png}}
 +
 +To add new block to header section, we can go to Admincp > Site Manager > Themes Manager > Layout Editor
 +
 +{{:​documentation:​3a186e965e748f88c354cd6db7affb47.png}}
 +
 +===== Customize CSS =====
 +
 +Themes can contain static assets as well as view files. A theme can include any necessary assets in its webroot directory. This allows for easy packaging and distribution of themes.
 +
 +To improve performance for production environments,​ it’s recommended that you either symlink or copy theme assets into the application’s webroot.
 +
 +To use the new theme webroot:
 +
 +<​code>​
 +app/​webroot/​theme/<​theme_name>/​css/​name_file.css
 +</​code>​
 +
 +For example: To change style theme from blue to red
 +
 +  * Go to app/​webroot/​theme/​redtheme/​css and create custom.css file
 +  * Go to app/​View/​Themed/​redtheme/​ , copy Layouts/​defaults.tpl from default to redtheme folder, then include custom.css
 +
 +<code php>
 +<?php
 +     echo $this->​Html->​css( array(
 +          '​custom.css?'​ . Configure::​read('​core.version'​)
 +     ));
 + ?>
 +
 +</​code>​
 +
 +  * Open custom.css file then apply the new style:
 +
 +<​code>​
 +
 +#header{
 +   ​background:​ #B90000;
 +}
 +.header-bg{
 +   ​background:​ #E60000;
 +}
 +</​code>​
 +
 +  * Open browser and check:
 +
 +{{:​documentation:​896a9f0b758a971018bc66675e801672.png}}
 +
 +===== Customize JS =====
 +
 +==== JavaScript in Template Files ====
 +
 +To use JavaScript repeatedly within your site, you can either set the call for the JavaScript, or the script itself, in the head of your **layout.ctp** ​ template file, between the meta tags and the style sheet link, no differently than you would if you were using JavaScript in any HTML page.
 +
 +To "​load"​ the JavaScript file into your site, in the head, add something like this:
 +
 +<code html4strict>​
 +echo $this->​Html->​script( array( '​file_name.js?'​ . Configure::​read('​core.version'​) ) );
 +
 +</​code>​
 +
 +==== JavaScript in single page ====
 +
 +To use JavaScript inside of single page, ex: blog index page, you need to take a few more steps. Odds are that this usage is for one or only a few instances, so adding the script to the header would be unnecessary. Make sure that each script is defined inside quote:
 +
 +<code php>
 +
 +<?php $this->​Html->​scriptStart(array('​inline'​ => false)); ?>
 + // Your code here
 +<?php $this->​Html->​scriptEnd();​ ?>
 +
 +</​code>​
 +
 +====== Export the theme ======
 +
 +To export the plugin, go to Admin > Home > Site Manager > Theme Manager, click download icon to export (See image)
 +
 +{{:​documentation:​1072ef2faf224d5a45b4ecef6a1f219a.png}}
 +
 +====== How to uninstall theme ======
 +
 +To uninstall the plugin, go to Admin > Home > Site Manager > Theme Manager, click recycle bin icon to uninstall (See image)
 +
 +{{:​documentation:​5218b868a8a4866310f781b4c419102f.png}}
 +
 +====== How to install theme ======
 +
 +  * Copy theme source code into /app/
 +  * Go to Admin > Home > Site Manager > Theme Manager, select tab "not uninstalled themes"​ and click install (See image).
 +
 +{{:​documentation:​7ccc0d3367f6ef178cc7c7ca638ff0cd.png}}
 +
 +//SAMPLE THEME:// ​ [[https://​www.moosocial.com//​wiki/​lib/​plugins/​ckgedit/​fckeditor/​userfiles/​file/​mytheme.zip|https://​www.moosocial.com//​wiki/​lib/​plugins/​ckgedit/​fckeditor/​userfiles/​file/​mytheme.zip]]
  
documentation/create_first_theme.1434350911.txt.gz · Last modified: 2015/08/24 01:13 (external edit)