MODx Community Forums
The MODx Blog
Donations
Feedburner Feeds
Documentation
Bugs & Requests
The Wiki
download MODx
plugins, modules, snippets
online demo
Sep 07, 2008, 01:55 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
modxcms.com
web
MODxCMS.com
Forums
Help
Login
Register
News
:Donate to MODx:
Donations
MODx Community Forums
»
Development & Coding
»
Module, Plugin & Snippet Creation and Modification
(Moderators:
zi
,
PaulGregory
)
»
[function] Smart ModX Url function (for snippet developers)
Pages: [
1
]
Go Down
« Previous topic
Next topic »
Print
Author
Topic: [function] Smart ModX Url function (for snippet developers) (Read 5399 times)
0 Members and 1 Guest are viewing this topic.
bS
Coding Team
Posts: 397
[function] Smart ModX Url function (for snippet developers)
«
on:
Jun 21, 2006, 07:51 AM »
I don't know if it's really usefull but I needed this functionality for pagination I include in my snippets.
The function will keep the original url+querystring and keep all values that are not changed intact. This way the link it produces works in every situation.
For example if your snippet is called together with another snippet that uses some querystring value you can't possibly now what that value will be unless you preserve the url. When you create a link to a certain ability of your own snippet it will not break the other snippet call.
you will give either a docid or a docalias of the link and put the extra querystring values in an array.
function
:
Code:
function smartModxUrl($docid, $docalias, $array_values) {
global $modx;
$array_url = $_GET;
$urlstring = array();
unset($array_url["id"]);
unset($array_url["q"]);
$array_url = array_merge($array_url,$array_values);
foreach ($array_url as $name => $value) {
if (!is_null($value)) {
$urlstring[] = $name . '=' . urlencode($value);
}
}
return $modx->makeUrl($docid, $docalias, join('&',$urlstring));
}
example usage:
Code:
$link['page'] = 3;
$link['aname'] = 'avalue';
$link['another'] = 'one';
echo smartModxUrl($modx->documentObject["id"],NULL, $link);
«
Last Edit: Jul 12, 2006, 03:12 PM by PaulGregory
»
Logged
Armand Pondman
MODx Coding Team
::
Jot
::
PHx
doze
Coding Team
Posts: 3,046
....Boom!
Re: Smart ModX Url function (for snippet developers)
«
Reply #1 on:
Jun 21, 2006, 08:02 AM »
Thanks, gonna implement this to the maxigallery pagination too.. don't know that is it needed in any case, but I can't think of all ways that the gallery snippet could be used, so I'll add this just for kicks..
But I'm a bit worried about
this issue
with makeUrl api call
Logged
MODxWiki
|| Please, list wiki worthy material
here
!
bS
Coding Team
Posts: 397
Re: Smart ModX Url function (for snippet developers)
«
Reply #2 on:
Jun 21, 2006, 08:37 AM »
Quote from: doze on Jun 21, 2006, 08:02 AM
Thanks, gonna implement this to the maxigallery pagination too.. don't know that is it needed in any case, but I can't think of all ways that the gallery snippet could be used, so I'll add this just for kicks..
But I'm a bit worried about
this issue
with makeUrl api call
well to be exact.. the reason i wrote this was because of the maxigallery+replix combination
so in reverse if someone adds comments to a gallery.. and you have pagination enabled there will be two pagination abilities (one in maxigallery and one in replix) if you switch to antoher page in the gallery, the comments will switch back to page 1 (that is if you don't preserve the querystring)
Logged
Armand Pondman
MODx Coding Team
::
Jot
::
PHx
Mark
Coding Team
Posts: 3,247
Ditto Developer
Re: Smart ModX Url function (for snippet developers)
«
Reply #3 on:
Jun 21, 2006, 09:06 AM »
What is the purpose of this line:
Code:
foreach ($array_values as $name => $value) {
$array_url[$name] = $value;
}
Logged
Documentation
TRAC (Bugtracker)
Forum
How to get help
User Wiki
Credits
SVN Server
Ditto HQ
Stable Download
Development Download
bS
Coding Team
Posts: 397
Re: Smart ModX Url function (for snippet developers)
«
Reply #4 on:
Jun 21, 2006, 09:11 AM »
unnecessary lines of code lol
can be replaced with
Code:
$array_url = $array_url + $array_values;
the lines fuses the $_GET array and the new values array (thus overwriting any previous value)
update: changed in original post
I also want to note that to completely remove a value from teh querystring you have to set it to NULL (not '')
like this: $array['name'] = NULL;
«
Last Edit: Jun 21, 2006, 09:14 AM by bS
»
Logged
Armand Pondman
MODx Coding Team
::
Jot
::
PHx
bS
Coding Team
Posts: 397
Re: Smart ModX Url function (for snippet developers)
«
Reply #5 on:
Jun 23, 2006, 06:49 AM »
again same line of code replaced with:
Code:
$array_url = array_merge($array_url,$array_values);
because of strange results in some situations.
Logged
Armand Pondman
MODx Coding Team
::
Jot
::
PHx
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.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 (and 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
=> Images, Videos & Podcasts
===> MaxiGallery
=> Manager, Parser & the Core
===> PHx
=> Templates
-----------------------------
General Discussions
-----------------------------
=> General MODx Discussions
=> Web Design and Development
=> Wishlist
=> You and Your Sites
=> modxcms.com Discussions and Suggestions
=> Off-topic
-----------------------------
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ışı