MODx Community Forums
The MODx Blog
Donations
Feedburner Feeds
Documentation
Bugs & Requests
The Wiki
download MODx
plugins, modules, snippets
online demo
Oct 07, 2008, 02:58 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
modxcms.com
web
MODxCMS.com
Forums
Help
Login
Register
News
:Read what MODx Developers say:
MODx Dev. Blogs
MODx Community Forums
»
Add-ons, Extensions & Elements
»
Creating & Repurposing Content
»
Ditto
(Moderators:
Mark
,
PaulGregory
)
»
NewsListing filtering - not working as expected
Pages: [
1
]
Go Down
« Previous topic
Next topic »
Print
Author
Topic: NewsListing filtering - not working as expected (Read 3681 times)
0 Members and 1 Guest are viewing this topic.
omnivore
Jr. Member
Posts: 46
Can this be real?
NewsListing filtering - not working as expected
«
on:
Apr 07, 2006, 01:47 PM »
i have a newslisting on my home page that looks like this:
Code:
[[NewsListing? &startID=`47` &summarize=`6` &total=`6` &tpl=`eventListingHome` &sortby=`tvtestSort` &sortdir=`asc` &truncText=`More` &filter=`tvtestSort,>[[unixtime]],1`]]
But I'm not getting the results I expected. [[unixtime]] is a snippet that does that, returns the unixtime. So the idea is that this would show items after (or before) the current unixtime. I can compare the value of the tv, testSort, and the unixtime returned by the snippet, and it isn't working. Depending on the last argument to filter, it either turns up all or none of the items, but there are values stored that are both higher and lower.
It occured to me that the NewsListing might not be able to parse the embedded snippet, although i wasn't sure why, but in any case, wrote another snippet that outputs the same text to the page, but substitutes mktime() for the [[unixtime]], and concatenates the whole together before writing it to the page, but that doesn't work either.
Any ideas why?
Logged
Web Designer
PHP Programmer
Cocoa Developer
Boulevardier & Arriviste
davidm
Marketing & Design Team
Posts: 6,651
The best way to predict the future is to invent it
Re: NewsListing filtering - not working as expected
«
Reply #1 on:
Apr 07, 2006, 02:06 PM »
Sorry for the dumb question but is the ">" supposed to be here in the call ? e.g ">[[unixtime]]"
Logged
blog.nodeo.net
:
Pour un web libre, moderne et ouvert!
:: |
! Nouveau !
Les forums modxcms.fr
:
Participez à l'élaboration du site MODx francophone !
! 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
|
gican.asso.fr
|
michelez-notaires.com
|
amadom.gerondicap.com
|
sworld.com
|
soleil.info
et 3 autres en cours de réalisation
Mark
Moderator
Posts: 3,247
Ditto Developer
Re: NewsListing filtering - not working as expected
«
Reply #2 on:
Apr 07, 2006, 02:10 PM »
I believe he wants it to be less than the current date and so he put that there. Omnivore, NewsListing does not yet support that because PHP doesn't execute if($var1 $sign $var 2) correctly and until I can find a workaround you'll have to swap the = in the code with the > (should be a piece of cake, if you need specific lines to change let me know [I don't have access to my code here]).
Logged
Documentation
TRAC (Bugtracker)
Forum
How to get help
User Wiki
Credits
SVN Server
Ditto HQ
Stable Download
Development Download
omnivore
Jr. Member
Posts: 46
Can this be real?
Re: NewsListing filtering - not working as expected
«
Reply #3 on:
Apr 07, 2006, 02:42 PM »
Quote from: Mark on Apr 07, 2006, 02:10 PM
I believe he wants it to be less than the current date and so he put that there. Omnivore, NewsListing does not yet support that because PHP doesn't execute if($var1 $sign $var 2) correctly and until I can find a workaround you'll have to swap the = in the code with the > (should be a piece of cake, if you need specific lines to change let me know [I don't have access to my code here]).
Thanks for the quick replies...
yes, that's what I want, for the test to be that the current time is less than the time recorded in the tv.
Okay... so what this means is that I need to hack NewsListing to work this way? Not quite sure what Mark is pointing at, but I haven't gone through the code yet. What comparisons can be in that middle argument? equality only? When you say that its a PHP thing, does that mean that the expression gets evaluated by PHP wrongly/unreliably?
Also - is there documentation for this somewhere, beyond the comments in the snippet? The stuff on the modxcms site seems to be out of date for 6.3.3
Logged
Web Designer
PHP Programmer
Cocoa Developer
Boulevardier & Arriviste
omnivore
Jr. Member
Posts: 46
Can this be real?
Re: NewsListing filtering - not working as expected
«
Reply #4 on:
Apr 07, 2006, 03:37 PM »
I think that this is the solution. In the area of the NewsListing code, at line 400, you find this loop:
Code:
foreach ($resources as $k=> $r) {
if( $filtertype == 1 && (!isset ($r[$filterKey]) || $r[$filterKey]!=$filterName) ) {
unset($resource[$k]);
} else if ( $filtertype == 2 && $r[$filterKey]==$filterName ) {
unset($resource[$k]);
}
}
I substituted this switch statement for the above. It gives six modes:
1 not equal
2 equal
3 less than
4 greater than
5 less than or equal
6 greater than or equal
Code:
foreach ($resources as $k=> $r) {
$unset = false;
switch ($filtertype){
case "!=" :
case 1 :
if (!isset ($r[$filterKey]) || $r[$filterKey]!=$filterName) $unset=true;
break;
case "=" :
case 2 :
if ($r[$filterKey]==$filterName) $unset=true;
break;
case "<" :
case 3 :
if ($r[$filterKey]<$filterName) $unset=true;
break;
case ">" :
case 4 :
if ($r[$filterKey]>$filterName) $unset=true;
break;
case "<=" :
case 5 :
if (!($r[$filterKey]<$filterName)) $unset=true;
break;
case ">=" :
case 6 :
if (!($r[$filterKey]>$filterName)) $unset=true;
break;
}
if ($unset) unset($resource[$k]);
}
in fact, the mode argument could just as easily be the operator sign, so I added those to the switch statement to make things a little less cryptic.
Haven't tested extensively, but seems to work.
Hope that's useful to someone.
Logged
Web Designer
PHP Programmer
Cocoa Developer
Boulevardier & Arriviste
Mark
Moderator
Posts: 3,247
Ditto Developer
Re: NewsListing filtering - not working as expected
«
Reply #5 on:
Apr 07, 2006, 05:52 PM »
Perfect!
Logged
Documentation
TRAC (Bugtracker)
Forum
How to get help
User Wiki
Credits
SVN Server
Ditto HQ
Stable Download
Development Download
Mark
Moderator
Posts: 3,247
Ditto Developer
Re: NewsListing filtering - not working as expected
«
Reply #6 on:
Apr 08, 2006, 10:23 AM »
Sorry about the brief response earlier, I was on my PSP and could only type out one word! That code is great! With a few modifications to allow both mode 1 and 2 for each of the sign versions I'll put that in the next release. Could you file that in the NewsListing BugTracker please? Thanks!
Logged
Documentation
TRAC (Bugtracker)
Forum
How to get help
User Wiki
Credits
SVN Server
Ditto HQ
Stable Download
Development Download
Mark
Moderator
Posts: 3,247
Ditto Developer
Re: NewsListing filtering - not working as expected
«
Reply #7 on:
Apr 09, 2006, 11:19 AM »
Added and released in NewsListing 6.4
Logged
Documentation
TRAC (Bugtracker)
Forum
How to get help
User Wiki
Credits
SVN Server
Ditto HQ
Stable Download
Development Download
omnivore
Jr. Member
Posts: 46
Can this be real?
Re: NewsListing filtering - not working as expected
«
Reply #8 on:
Apr 11, 2006, 04:02 PM »
Quote from: Mark on Apr 08, 2006, 10:23 AM
Sorry about the brief response earlier, I was on my PSP and could only type out one word! That code is great! With a few modifications to allow both mode 1 and 2 for each of the sign versions I'll put that in the next release. Could you file that in the NewsListing BugTracker please? Thanks!
Too kind.
I went away for a few days - since its in the 6.4, I'll assume that you don't need the bugtracker entry...
Logged
Web Designer
PHP Programmer
Cocoa Developer
Boulevardier & Arriviste
Mark
Moderator
Posts: 3,247
Ditto Developer
Re: NewsListing filtering - not working as expected
«
Reply #9 on:
Apr 11, 2006, 04:04 PM »
I believe I already closed the entry, marking it as complete. BTW, 6.4 actually has the ability to have the entire NL template change and not just a class so you have alot more power.
Logged
Documentation
TRAC (Bugtracker)
Forum
How to get help
User Wiki
Credits
SVN Server
Ditto HQ
Stable Download
Development Download
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
=> Images, Videos & Podcasts
===> MaxiGallery
=> Manager, Parser & the Core
===> 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ışı