MODx Community Forums
The MODx Blog
Donations
Feedburner Feeds
Documentation
Bugs & Requests
The Wiki
download MODx
plugins, modules, snippets
online demo
Nov 20, 2008, 05:47 PM
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
Frequently Asked Questions (FAQ)
MODx Community Forums
»
Add-ons, Extensions & Elements
»
Module, Plugin & Snippet Usage
(Moderators:
zi
,
PaulGregory
)
»
[Snippet] getdoc
Pages: [
1
]
Go Down
« Previous topic
Next topic »
Print
Author
Topic: [Snippet] getdoc (Read 7370 times)
0 Members and 1 Guest are viewing this topic.
Mark
Coding Team
Posts: 3,247
Ditto Developer
[Snippet] getdoc
«
on:
Dec 04, 2005, 12:31 PM »
This snippet gets a specific field (any of these
http://modxcms.com/the-document-object.html
) for an individual document.
Example call that will return the content of the first document (id 1):
Code:
[[getdoc? &id=1 &field=`content`]]
Snippet code:
Code:
$id = isset($id)? $id: $modx->documentObject['id'];
$field = isset($field)? $field : "pagetitle";
$result = $modx->getDocument($id,$field);
return $result[$field];
«
Last Edit: Jan 02, 2006, 07:14 PM by Mark
»
Logged
Documentation
TRAC (Bugtracker)
Forum
How to get help
User Wiki
Credits
SVN Server
Ditto HQ
Stable Download
Development Download
zi
MODx Special Forces /
Administrator
Posts: 3,003
May Peace Be On You
Re: [Snippet] getdoc
«
Reply #1 on:
Dec 04, 2005, 12:34 PM »
Very nice little snippet !
Thanks for sharing.
regards,
zi
Logged
Subscribe to
MODx Commercial Support Plans
“Internet Explorer’s CSS rendering: WYSIWTF”. — someone genius
--------------------------------------------------
MODx Docs
MODx Wiki
Bug Tracker
Download Center
Donations
Forum Rules
ziDesigns
ziDesigns Resources
ziworks | Custom/Free MODx Templates
banzai
Testers
Posts: 857
MODx Italia
Re: [Snippet] getdoc
«
Reply #2 on:
Dec 04, 2005, 12:51 PM »
great useful snippet! thanks!
Logged
MODx Websites Showcase
Add your site to
www.modx.it
!
-----------------------------------------------------
FREE MODx Templates
www.tattoocms.it
-----------------------------------------------------
VIDEO: whats new in MODx 0.9.5
|
VIDEO: MODx PHP Application Framework
|
bubuna.com - Web & Multimedia Design
rthrash
Foundation
Posts: 9,510
Re: [Snippet] getdoc
«
Reply #3 on:
Dec 04, 2005, 03:40 PM »
Does it get the raw code or the parsed output?
Logged
MODx
is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you
help us help you
,
read the wiki
, and review snippet parameters – even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @
Collabpad
work
productively.
work
intelligently.
work
together.
MODx
Current
|
Dev
|
SVN Root
|
JIRA (Bugs)
|
Confluence (097 Wiki)
|
Fisheye SVN Browser
Mark
Coding Team
Posts: 3,247
Ditto Developer
Re: [Snippet] getdoc
«
Reply #4 on:
Dec 04, 2005, 03:55 PM »
Parsed output.
Sorry folks I copied and pasted the wrong version!
I updated the first post with the correct version!
Logged
Documentation
TRAC (Bugtracker)
Forum
How to get help
User Wiki
Credits
SVN Server
Ditto HQ
Stable Download
Development Download
davidm
Marketing & Design Team
Posts: 6,733
The best way to predict the future is to invent it
Re: [Snippet] getdoc
«
Reply #5 on:
Dec 05, 2005, 04:08 AM »
Thanks Mark for this much needed snippet, I can think of a few uses for it
Logged
.:
david-molliere.net
:
Pour un web libre, moderne et ouvert!
::
Forums modxcms.fr
:
Participez à l'élaboration du site MODx francophone !
:.
! Nouveau !
En live, ne manquez pas les news de modxcms.fr sur Twitter
! Nouveau !
MODx est l'outil idéal pour les developpeurs et webdesigners qui cherchent un framework de gestion de contenu hautement flexible et performant, tout en étant simple d'accès pour les utilisateurs finaux.
Config :
Apache 2.2.8 - MySQL 5.0.45 - PHP 5.2.6 | Debian 4.0 (Etch)
Réalisations sous MODx :
nodeo.net
|
pargade-notaires.fr
|
soleil.info
|
gican.asso.fr
|
michelez-notaires.com
|
amadom.gerondicap.com
|
jocelyne-violet.net
rthrash
Foundation
Posts: 9,510
Re: [Snippet] getdoc
«
Reply #6 on:
Dec 05, 2005, 08:28 AM »
Both versions would be useful actually (parsed and raw unparsed).
Logged
MODx
is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you
help us help you
,
read the wiki
, and review snippet parameters – even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @
Collabpad
work
productively.
work
intelligently.
work
together.
MODx
Current
|
Dev
|
SVN Root
|
JIRA (Bugs)
|
Confluence (097 Wiki)
|
Fisheye SVN Browser
luke.stokes
Support Subscriber
Posts: 54
Re: [Snippet] getdoc
«
Reply #7 on:
Mar 01, 2006, 05:00 PM »
Slight modification to look for a template variable:
Code:
// Determine the target document, defaulting to self if nothing specified
$id = (!isset($id)) ? $modx->documentObject['id'] : "$id";
// Document field to get
$field = (!isset($field)) ? 'pagetitle' : "$field";
$array = $modx->getDocument($id);
$output = $array[$field] ;
if (!$output) {
// try to get a template variable
$TVarray = $modx->getTemplateVar($field, "*", $id);
$output = $TVarray["value"];
if (!$output) {
$output = $array['pagetitle'];
}
}
return $output;
Logged
dogas
Jr. Member
Posts: 10
I love MODx!
Re: [Snippet] getdoc
«
Reply #8 on:
Mar 02, 2006, 01:32 PM »
Great snippet, although for some documents I request I'm getting no output when I request the content, although the "source retrieved from cache" gives me the following:
Code:
<?php
die(
'Unauthorized access.'
);
.
Any help would be greatly appreciated. Thanks.
Logged
luke.stokes
Support Subscriber
Posts: 54
Re: [Snippet] getdoc
«
Reply #9 on:
Mar 02, 2006, 02:01 PM »
Hmm... does it work fine without the modification I made? I just put in a quick hack, I didn't do any security testing. It may be that the template variable you're requesting has specific document permissions on it which would cause the getTemplateVar call to fail. I'd try taking a look at the "some documents" to find a pattern and see if you are requesting info from pages that have security on them.
Hope that helps.
Logged
dogas
Jr. Member
Posts: 10
I love MODx!
Re: [Snippet] getdoc
«
Reply #10 on:
Mar 02, 2006, 02:14 PM »
I'm using both versions of your code. Both of which return a blank output. I think the "unauthorized access" message is because of a caching issue, which I turned off for the test page I am using.
Is there any other way to debug what might be going on? Does MODx log output anywhere?
Logged
luke.stokes
Support Subscriber
Posts: 54
Re: [Snippet] getdoc
«
Reply #11 on:
Mar 02, 2006, 03:14 PM »
Well, there's the "Event log viewer" under the Administration tab and the Audit trail. Are you calling the snippet cached or unchached ([[getDoc]] or [!getDoc!]). I need learn more about the differences between the two, but I've always been told to use [! !] which does not cache.
Sorry I couldn't be more helpful.
Logged
dogas
Jr. Member
Posts: 10
I love MODx!
Re: [Snippet] getdoc
«
Reply #12 on:
Mar 02, 2006, 03:33 PM »
Well, I've sort of figured it out. It seems for me the getdoc function works correctly if the page does not use a tempate that has template variables. If i try to get a page the is based on a template that has template variables, it spits out a blank page.
Oh well, back to the drawing board. Thanks again for your help!
Logged
luke.stokes
Support Subscriber
Posts: 54
Re: [Snippet] getdoc
«
Reply #13 on:
Mar 03, 2006, 01:00 AM »
Well, you found a pattern, but I don't think that's the problem. All template variables are associated with templates. So in order to use the getDoc to grab a template variable, by definition the page you are looking for has to have a template (with template variables).
I'd look again at your template variables and the document security you have set for them. That would explain the access error you got.
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ışı