Fork me on GitHub
Get XOOPS XOOPSXOOPS FAQFAQ ForumsForums NewsNews ThemesThemes ModulesModules
News World of XOOPS Developers Hacks Modules Themes YAXS Archive Submit News

Search

Donat-O-Meter

Make donations with PayPal!
Stats
Goal: $100.00
Due Date: Sep 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00

Learn XOOPS Core

Local Support

Advertisement

XOOPS Code hosted on SourceForge

Cumulus Tag Cloud

- 2 2.5 2.6 3.0 4 6 2013 adslight Android AntiHarvesting AntiMalUser AntiSpam API Apple Battlefield billige Bootstrap Captcha cell cent chronolabs CHUNG Clicks content CĂN demo docek download Dresses evden eve facebook Fat floor Food for free Gateway Google Guide herre Home Honeypot HP Human HỘ IP iPhone jQuery Language List log Loss mobile module modules Monster new newbb news NHÀ online PARK phone PHP Prevention profile project Protector publisher Rapid RESIDENCE responsive review Rights rmcommon security Sentry site Smartphone Smoking Solution Spam stem Studio tdmcreate template The Theme themes web weight Wishcraft xoops Xortify XPayment ZendFramework

New Users

Registering user

# 137767

obdvip

Welcome to XOOPS!

Archives

News Archives

Using templates pages in modules

Posted by alain01 on 2013/1/10 11:30:00 (4498 reads) | Posted on Tutorials
Hello,

A lot of people using XOOPS, need to use templates for presenting homogeneous pages :

- cooking,
- some books,
- some movies,
- ...

I would show you how to use a template to generate your pages :

Advantages:

- Same template for all pages
- Homogeneous and more clear presentation
- Using of pre-defiined pages


Creating a Template (gabarits) in 6 steps:

1 - TinyMCE editor activation for modules
2 - Add the template botton
3 - Create template files
4 - Create a definition file for templates
5 - upload files on server
6 - Use



1 - TinyMCE editor activation for modules (See this editor in demo here)
Administration / Preferences / systeme Module Settings / Editor Settings / Editor for all modules: : tinymce
(or choose TinyMCE for default editor for the module that you will use, in module preferences)


2 - Add the template button

Modify the file /class/xoopseditor/tinymce/settings.php:

Line 70, change
"paste,fullscreen,visualchars,nonbreaking,inlinepopups",
by
"paste,fullscreen,visualchars,nonbreaking,inlinepopups,template",

then line 85
"theme_advanced_buttons4" => "xoopsimagemanager,xoopsemotions,xoopsquote,xoopscode,xoopsmlcontent",
by
"theme_advanced_buttons4" => "xoopsimagemanager,xoopsemotions,xoopsquote,xoopscode,xoopsmlcontent,template",
"template_external_list_url" => '/uploads/gabarits/liste-gabarits.js',

(Here it is for indicate that templates are in the directory /uploads/gabarits and definition's file of the template is liste-gabarits.js


3 - Create template files

Theses files must be in html format, but without < html >, < body > or <head >
Here, we create 2 html files:

- fiche-cooking.html,
- fiche-book.html.

Please, make a clean html file, with fixed positions...
For example, for the template 'cooking' :
Title of the cooking :
Ingredients :
Difficulty to make :
...

4 - Create the definition's file of the template

Here, create the file liste-gabarits.js :
// JavaScript Document 

var tinyMCETemplateList = [ 

// Nom, URL, Description 

["Fiche cuisine""/_uploads/gabarits/fiche-cooking.html""Template for the cooking."], 

[
"Fiche Livre""/_uploads/gabarits/fiche-book.html""Template for books."] ];



5 - upload files on server

On /uploads/gabarits, uploads files :

- liste-gabarits.js
- fiche-cooking.html,
- fiche-book.html.
- index.htlm ( same as in another directory)


6 - Use

Go to module (news for example), then click on the "template" icon then, in the opening window, select the template that you want to use (fiche-cooking for create a page for "Apple cake", for example)

Thats' all !

It is nice ?

Let me know what you think. I will appreciate your comments !

PS 1 : Big thanks to montuy337513 for the support in the XOOPS France Forum.

PS 2 : it would be nice to have this option available by default in the next XOOPS version, wouldn't it?


Tags: template   editor   TinyMCE  
Printer Friendly Page Send this Story to a Friend Create a PDF from the article
Bookmark Me
Bookmark to Google Plus
The comments are owned by the author. We aren't responsible for their content.

Thanks alain01, great job!

I think you have to replace :

// JavaScript Document 

var tinyMCETemplateList = [  

// Nom, URL, Description 

["Fiche cuisine""/_uplods/gabarits/fiche-cooking.html""Template for the cooking."], 

[
"Fiche Livre""_uplods/gabarits/fiche-book.html""Template for books."] ];



with :

// JavaScript Document 

var tinyMCETemplateList = [  

// Nom, URL, Description 

["Fiche cuisine""/_uploads/gabarits/fiche-cooking.html""Template for the cooking."], 

[
"Fiche Livre""_uploads/gabarits/fiche-book.html""Template for books."] ];

Published: 2013/1/10 15:10 • Updated: 2013/1/10 15:10
Please, modify the news here :

Quote:
// JavaScript Document
var tinyMCETemplateList = [

// Nom, URL, Description
["Fiche cuisine", "/_uploads/gabarits/fiche-cooking.html", "Template for the cooking."],

["Fiche Livre", "/_uploads/gabarits/fiche-book.html", "Template for books."] ];

Published: 2013/1/10 17:19 • Updated: 2013/1/10 21:07
Nice tutorial, must be corrected and moved to Wiki for localization...
Published: 2013/1/12 8:22 • Updated: 2013/1/12 8:22