MODx Community Forums
The MODx Blog
Donations
Feedburner Feeds
Documentation
Bugs & Requests
The Wiki
download MODx
plugins, modules, snippets
online demo
Dec 04, 2008, 01:07 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search via SMF
or Google:
modx forums
all of modxcms.com
web
MODxCMS.com
Forums
Help
Login
Register
News
:Read what MODx Developers say:
MODx Dev. Blogs
MODx Community Forums
»
Development & Coding
»
Templates
(Moderators:
zi
,
PaulGregory
)
»
store templates in file system?
Pages: [
1
]
Go Down
« Previous topic
Next topic »
Print
Author
Topic: store templates in file system? (Read 10767 times)
0 Members and 1 Guest are viewing this topic.
erotte
Jr. Member
Posts: 13
store templates in file system?
«
on:
May 01, 2006, 05:53 PM »
Hi there,
a simple question:
why are templates stored to the database?
It is much more easy to edit a template when its stored in the file system.
In cmsimple theres a way to call templates from file system via an include.
Is there a similar way in modx?
Logged
OpenGeek
MODx Co-Founder
Foundation
Posts: 5,054
looking a little more like my avatar again...
Re: store templates in file system?
«
Reply #1 on:
May 01, 2006, 06:00 PM »
Templates are stored to the database because the folks who originally designed Etomite did it that way. Content in the database vs. the filesystem is an argument as old as content management. I personally keep copies of all my templates in the filesystem and edit those, then copy and paste in the manager. But it's just as easy to write a snippet to include your templates from the file system, then simply use a single template in MODx to wrap it with anything else you might not want in the template (might be a blank template with nothing but a snippet call in it). I believe someone has done something similar and posted about it here, but I'd have to search for it.
Logged
Jason Coward
MODx Co-Founder
xPDO Founder
Principal @
Collabpad
work
productively.
work
intelligently.
work
together
.
MODx
Development
|
SVN
|
Fisheye
xPDO
Development
|
SVN
|
Fisheye
The spirit of a warrior is not geared to indulging and complaining, nor is it geared to winning or losing. The spirit of the warrior is geared only to struggle, and every struggle is a warrior's last battle on earth. Thus the outcome matters very little to him. In his last battle on earth a warrior lets his spirit flow free and clear. And as he wages his battle, knowing that his intent is impeccable, a warrior laughs and laughs.
— don Juan Matus
doze
Coding Team
Posts: 3,237
....Boom!
Re: store templates in file system?
«
Reply #2 on:
May 02, 2006, 04:31 AM »
There is allready ready made snippet for this (to have templates/snippets/whatever in filesystem and just include them at manager), and there is also discussion about this in some threads, see
here
for example and do a seach with "include" for more information.
Logged
MODxWiki
|| Please, list wiki worthy material
here
!
Marschant
Full Member
Posts: 133
Re: store templates in file system?
«
Reply #3 on:
May 02, 2006, 04:44 AM »
My approach is to create a "GLOBAL" template, well that's what I called it anyway, containing the following:
Code:
[[includeFile?&phpfile=[*templatePath*]/template/template.php]]
Within a document I have a template variable called templatePath that I've setup with @INHERIT as the default property. I then set each master folder or documents "templatePath" TV to something like "assets/issues/march" or whatever you want to call it.
In the file system I have "assets/issues/march/template/template.php" and sub-folders containing all my css and images. Within the php template I use the TV value for linking to stylesheets and images, and in certain cases have found that I need to set a php path variable as well.
Not sure how complicated your setup is going to be but I've found this works really well for me. You see I'm doing a monthly ezine and each issue has a different feel so managing multiple templates with the Manager was a nightmare, with this approach I use a single template and change the path to what it includes - sweet - no more stressing!!!
If you need some more help please don't hesitate to ask.
Logged
erotte
Jr. Member
Posts: 13
Re: store templates in file system?
«
Reply #4 on:
Jun 03, 2006, 08:40 AM »
Quote from: Marschant on May 02, 2006, 04:44 AM
My approach is to create a "GLOBAL" template, well that's what I called it anyway, containing the following:
Code:
[[includeFile?&phpfile=[*templatePath*]/template/template.php]]
Ups, one month ago - but many thanks, this seems to be a good solution!
Greetings
E.
Logged
gunner
Jr. Member
Posts: 12
Re: store templates in file system?
«
Reply #5 on:
Jun 07, 2006, 03:49 PM »
I am trying to implement this with not much luck. Can you describe the process, what goes where to make this call? TIA
Logged
Marschant
Full Member
Posts: 133
Re: store templates in file system?
«
Reply #6 on:
Jun 08, 2006, 03:06 AM »
Quote from: gunner on Jun 07, 2006, 03:49 PM
I am trying to implement this with not much luck. Can you describe the process, what goes where to make this call? TIA
My approach is the following:
Create a new directory within the assets/templates folder
Create your master template as template.php or whatever you want to call it. This is your html with any references to stylesheets, scripts, template variables or placeholders within it.
Search for the includeFile snippet and install it or use the code pasted below
Setup a new template within the manager insert a includeFile snippet call (see below)
Modify any existing template variables within the manager that will need access to this template
Create a new document that uses the newly created template, add some content, publish and browse to it, hopefully everything worked out well
includeFile Snippet
Code:
# For example to include cutenews, you can use
# [[includeFile?template=nicetemplate&phpfile=cutenews/show_news.php]].
# You can offcourse pass any variable to the snippet to use for the included file.
if ( !isset($phpfile) || $phpfile == "" ) return "No file specified."; //check if there's a file given.
//Start the buffer
ob_start();
//include
include $phpfile;
//get contents from the buffer
$ob_contents = ob_get_contents();
//and kill/delete the buffer
ob_end_clean();
//return it to MODX.
return $ob_contents;
snippet call within a newly defined template in the manager
Code:
[[includeFile?&phpfile=[*templatePath*]/template/template.php]]
or
Code:
[[includeFile?&phpfile=assets/templates/mytemplate/template.php]]
I use a templatePath variable because I've moved all my resources to "assets/issues/year/month" because each monthly issue I publish has a different look and feel to it. You probabely won't need to worry about something like this.
If you need me to post the actual content of template.php please let me know.
Logged
gunner
Jr. Member
Posts: 12
Re: store templates in file system?
«
Reply #7 on:
Jun 08, 2006, 03:41 PM »
Worked perfectly! Thanks so much.
Logged
Marschant
Full Member
Posts: 133
Re: store templates in file system?
«
Reply #8 on:
Jun 09, 2006, 03:13 AM »
Glad I could help!
Logged
MikeT
Jr. Member
Posts: 30
___me_sleepy___
Re: store templates in file system?
«
Reply #9 on:
Jul 16, 2006, 07:49 PM »
I was wondering if you could link the template code, and got directed here by the ever helpfull Sottwell.
Thanks Marschant, read your post and even though I could not get it to work the way you described (my issues!) I found it helped my brain spark with some new ideas.
I re-read some of the MODx documentation and found the
TV @FILE.
What I did for a solution was:
1. Create a TV called
[*templatePath*]
2. Default value
@FILE assets/templates/index.html
(or to where you file is)
3. Set the
Template Access
4. Then put the TV
[*templatePath*]
in your template code
The great thing about this is you can then edit your code within a text editor and because it is linked you do not have to continue to cut and paste all the time.
This works perfectly for me and my workflow.
I use Style Master and Skedit.
Stylemaster lets you use any on line document to preview what your CSS looks like from with Stylemaster app itself. So the way I can work is:
1. Linked template code to MODx.
2. Style master uses
localhost/mysite/index.php?id=4
(non_friendly) as my preview doc.
3. Skedit to edit code.
So it works as a nice little loop. However I am having trouble with the page sticking in the cache.
Any suggestions to this would be great!
Thanks all.
Logged
Pages: [
1
]
Go Up
Print
« Previous topic
Next topic »
Jump to:
Please select a destination:
-----------------------------
Announcements
-----------------------------
=> Important News
=> Security Notices
-----------------------------
Commercial Support
-----------------------------
=> [CS] About Commercial Support
-----------------------------
Development & Coding
-----------------------------
=> Commercial Inquiries & Bounties
=> Core Code
===> MODx Next
===> xPDO
=> Module, Plugin & Snippet Creation and Modification
=> In Development
=> Templates
=> Internationalization
===> Bulgarian
===> Chinese
===> Czech
===> Dutch
===> French
===> German
===> Irish
===> Italian
===> Japanese
===> Polish
===> Portuguese
===> Russian
===> Slovak
===> Spanish
===> Swedish
===> Persian - فارسي
-----------------------------
Support
-----------------------------
=> Release Support
===> 0.9.6.2
===> 0.9.6.1
===> 0.9.6
===> 0.9.5 and earlier
=> General Support
===> MODx 101
===> E-Commerce, E-Marketing, Analytics & SEO
===> Hosting Experiences
===> IIS / Windows Hosting Issues
=> Documentation, Tips & Tricks
===> Documentation Suggestions & Corrections
-----------------------------
Add-ons, Extensions & Elements
-----------------------------
=> Module, Plugin & Snippet Usage
=> General Repository Items Support
=> Navigation & Tagging/Taxonomy
===> Wayfinder & DropMenu
=> Creating & Repurposing Content
===> Ditto
===> Jot
===> QuickEdit
=> Users, Authentication & Personalization
===> WebloginPE
===> WebLogin, WebSignup and WebChangePwd
=> Rich Text Editors & File Browser
===> TinyMCE
===> FCKeditor
===> MCPuck File Browser
=> Forms, Form Processing & Anti-Spam
===> eForm
=> Search
===> AjaxSearch
=> E-business
=> Polls, Calendars, Address Book and Community
=> Third-party integrations
=> Images, Videos & Podcasts
===> MaxiGallery
=> Manager, Parser & the Core
===> Backup & Versioning
===> Doc Finder
===> ManagerManager
===> PHx
=> Templates
-----------------------------
General Discussions
-----------------------------
=> General MODx Discussions
=> Web Design and Development
=> Wishlist
=> You and Your Sites
=> modxcms.com Discussions and Suggestions
=> Off-topic
-----------------------------
Czech Community
-----------------------------
=> Oznámení
===> Důležitá oznámení/novinky
===> Bezpečnost
=> Podpora
===> FAQ (často kladené otázky)
===> Instalace
===> Moduly, pluginy, "snippets & code" (šablony zdrojových kódů)
===> Design & Šablony
=> Dokumentace, tutoriály (návody) a překlady
===> Dokumentace
===> Tutoriály (návody)
===> Překlady (lokalizace)
=> Komunita
===> Oznámení
===> Představte se, prosím
===> Ukázky práce
===> Různé aneb cokoli co se jinam nehodí
-----------------------------
Bulgarian Community
-----------------------------
=> Поддръжка
===> Често задавани въпроси
===> Инсталация
===> Модули, Плъгини, Снипети и код
===> Дизайн и Шаблони
=> Документация, Ръководства и Превод
===> Документация
===> Ръководства
===> Превод
=> Общество
===> Съобщения
===> Представете се
===> Представете сайта си
===> Дискусии извън MODx
-----------------------------
Dutch Community
-----------------------------
=> Ondersteuning
===> Veel gestelde vragen
===> Modules, Plugins, Snippets & Code
===> Design & Templates
=> Documentatie, Tutorials en Vertalingen
===> Documentatie
===> Tutorials
===> Vertalingen
=> Community
===> Aankondigingen
===> Stel jezelf voor
===> Site Showcase
===> De stamkroeg
-----------------------------
Finnish Community
-----------------------------
=> Tuki
===> UKK
===> Asennus
===> Moduulit, liitännäiset, koodinpätkät
===> Ulkoasu/Sivustopohjat
=> Dokumentaatio, oppaat ja käännökset
===> Dokumentaatio
===> Käännökset
===> Oppaat
=> Yhteisö
===> Tiedotteet
===> Esittele itsesi
===> MODx sivustosi
===> Kahvihuone
-----------------------------
Filipino Community
-----------------------------
=> Suporta
===> Kadalasang tanong
===> Instalasyon
===> Moduler, Maidadagdag, Karagdagang mga Code
===> Desenyo at Templates
=> Dokumentasyon, Mga Turo, Mga Salin
===> Dokumentasyon
===> Mga Turo
===> Mga Salin
=> Kumunidad
===> Anunsyo
===> Ipakilala ang sarili
===> Ang Galing ng pinoy
===> Tsismisan atbp
-----------------------------
French Community
-----------------------------
=> Support
===> FAQ
===> Installation
===> Module, plugin, snippets
===> Design/Templates
=> Documentation, Tutoriels et Traductions
===> Documentation
===> Traduction
===> Tutoriels
=> Communauté
===> Annonces
===> Présentez vous
===> Vos sites
===> Le Bistrot Français
-----------------------------
German Community
-----------------------------
=> Support (de)
===> FAQ (de)
===> Installation (de)
===> Module, Plugins, Snippets & Code (de)
===> Design & Templates (de)
=> Dokumentation, Tutorials und Übersetzung
===> Dokumentation
===> Tutorials (de)
===> Übersetzung
=> Community (de)
===> Ankündigungen
===> Stellt Euch vor
===> Beispielseiten
===> Off Topic / Verschiedenes
-----------------------------
Irish Community
-----------------------------
=> Tacaíocht
===> CC Ceisteanna Coitianta
===> Breiseáin (cláir bhreise), Snippets & Comhaid
===> Suiteáil
===> Dearadh & Teimpléid
=> Doiciméid, Teagascóireacht agus Aistriúchán
===> Doiciméadú
===> Teagascóireacht
===> Aistriúchán
=> Pobal
===> Fógraí
===> Cuir Tú Féin in Aithne
===> Gailearaí an Láithreáin
===> Caifé / An Tábhairne / Ábhar Cainte Eile / Ilghnéitheach
-----------------------------
Italian Community
-----------------------------
=> Supporto
===> FAQ
===> Installazione
===> Moduli, Plugin, Snippet e altro codice
===> Web Design e Template
=> Documentazione, Tutorial e Traduzione
===> Documentazione
===> Tutorial
===> Traduzione
=> Comunità
===> Annunci
===> Presentazioni
===> Siti in vetrina
===> Chiacchiere in libertà
-----------------------------
Japanese Community
-----------------------------
=> サポート
===> 良くある質問
===> インストール
===> モジュール・プラグイン・スニペット・本体
===> デザインやテンプレート
=> マニュアル・テュートリアル・翻訳
===> マニュアル
===> 事例集、テュートリアル
===> 日本語化
=> コミュニティ
===> お知らせ
===> MODxサイト展示場
===> 自己紹介
===> 雑談
===> 国産リソース
-----------------------------
Persian Community
-----------------------------
=> پشتيباني
===> راهنما
===> نصب
===> ماژول , پلاگین ها , کد ها و جزییات
===> طراحی و قالب ها
=> مستند سازی , آموزش ها و ترجمه ها
===> مستند سازی
===> آموزش ها
===> ترجمه ها
=> انجمن ها
===> اخبار
===> معرفی کردن خود
===> نمایش دادن سایت ها
===> بحث های عمومی و سایر موضوعات
-----------------------------
Polish Community
-----------------------------
=> Wsparcie
===> FAQ
===> Instalacja
===> Moduły, pluginy, snipety i kod
===> Wygląd i szablony
=> Dokumentacja, tutoriale i tłumaczenie
===> Dokumentacja
===> Tutoriale
===> Tłumaczenie
=> Społeczność
===> Ogłoszenia
===> Przedstaw się
===> Twój serwis WWW
===> Hyde Park
-----------------------------
Portuguese Community
-----------------------------
=> Suporte
===> FAQ - Dúvidas Frequentes
===> Instalação
===> Módulos, Plugins, Snippets e Código
===> Design e Templates
=> Documentação, Guias e Traduções
===> Documentação
===> Guias
===> Traduções
=> Comunidade
===> Anúncios
===> Apresente-se!
===> Bar da esquina (fora de tópico)
===> Portfólio de Sites
-----------------------------
Russian Community
-----------------------------
=> Поддержка
===> ЧАВО (FAQ)
===> Установка
===> Модули, плагины, сниппеты и код
===> Дизайны и шаблоны
=> Документация, Уроки, Перевод
===> Документация
===> Уроки
===> Перевод
=> Сообщество
===> Объявления
===> Представьтесь публике
===> Галерея сайтов
===> Диван
-----------------------------
Scandinavian Community
-----------------------------
=> Support
===> Frågor och svar
===> Installation
===> Moduler, plugins, snippets och kod
===> Design & sidmallar
=> Dokumentation, guider och översättningar
===> Dokumentation
===> Guider
===> Översättningar
=> Webbgemenskap
===> Meddelanden
===> Presentera dig själv
===> Visa upp dina webbsidor
===> Ordet fritt
-----------------------------
Spanish Community
-----------------------------
=> Soporte
===> FAQ
===> Instalación
===> Modulos, Plugins, Snippets & Código
===> Diseño y plantillas
=> Documentación, Tutoriales y Traducciones
===> Documentatción
===> Tutoriales
===> Traducciones
=> Comunidad
===> Anuncios
===> Presentaciones personales
===> Muestra de sitios
===> El Café
-----------------------------
TÜRKÇE (Turkish)
-----------------------------
=> Destek
===> SSS
===> Kurulum
===> Modüller, Pluginler, Snippetlar & Kodlar
===> Dizayn & Temalar
=> Belgeleme, Eğitmenler ve Çeviri
===> Belgeleme
===> Eğitmenler
===> Çeviri
=> Topluluk
===> Duyurular
===> Kendinizi Tanıtın
===> Site Vitrini
===> Konu Dışı