MODx Community Forums
The MODx Blog
Donations
Feedburner Feeds
Documentation
Bugs & Requests
The Wiki
download MODx
plugins, modules, snippets
online demo
Dec 04, 2008, 12:57 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
»
Add-ons, Extensions & Elements
»
Module, Plugin & Snippet Usage
(Moderators:
zi
,
PaulGregory
)
»
[Snippet] FlexSearchForm. Modified to hide private docs and add weblink feature.
Pages: [
1
]
Go Down
« Previous topic
Next topic »
Print
Author
Topic: [Snippet] FlexSearchForm. Modified to hide private docs and add weblink feature. (Read 4025 times)
0 Members and 1 Guest are viewing this topic.
steph
Member
Posts: 85
[Snippet] FlexSearchForm. Modified to hide private docs and add weblink feature.
«
on:
Apr 30, 2006, 07:09 PM »
Update 05//02/2007:
Fixed two problems whereby php complained that a function was being declared twice or didn't exist.
Update 11/07/2006:
I've replaced the attached zip file with 3 new ones - a zip, a gzip and a txt - because people were having problems unzipping the original.
Hi all.
I've modified the FlexSearchForm snippet to support the following:
Access control, i.e. hide private documents if the user doesn't have permission to view them. This functionality uses code lifted from the MODx getDocumentObject method in document.parser.class.inc.php.
Added better support for weblinks.
The new parameters are as follows:
&useWeblink
- [ true | false ] If true and the doc is of type 'reference', link to the doc's weblink (it's 'content' field) rather than to the doc itself. Defaults to false.
&weblinkClass
- [ string ] CSS class for a weblink's anchor. Defaults to "weblink".
Note that the code I modified was that of MadeMyDay's (posted on the MODx forums at
http://modxcms.com/forums/index.php/topic,2762.0.html
) which added support for showing an extract of the context with highlighted search terms. The display of content extracts makes it particularly important to prevent private documents being listed to those without permission to view them.
Steph
FlexSearchFormMindspillDotNet.php.txt
(20.01 KB - downloaded 158 times.)
«
Last Edit: Feb 05, 2007, 05:45 PM by steph
»
Logged
Stephan Dale
http://mindspill.net/computing/cross-platform-notes/modx.html
modx(a)mindspill.net
0ad
Full Member
Posts: 100
Re: [Snippet] FlexSearchForm. Modified to hide private docs and add weblink feat
«
Reply #1 on:
Jul 06, 2006, 08:15 AM »
Hi
Thanks for sharing, but the zip seems to corrupt when i download it, is it a problem for anyone else?
Cheers
0
Logged
Please consider the research and evidence of the Scholars for 9/11 Truth at
http://www.st911.org
steph
Member
Posts: 85
Re: [Snippet] FlexSearchForm. Modified to hide private docs and add weblink feat
«
Reply #2 on:
Jul 06, 2006, 09:23 AM »
Just tried downloading and unzipping. Worked fine for me. Can you try a different zip program?
Logged
Stephan Dale
http://mindspill.net/computing/cross-platform-notes/modx.html
modx(a)mindspill.net
0ad
Full Member
Posts: 100
Re: [Snippet] FlexSearchForm. Modified to hide private docs and add weblink feat
«
Reply #3 on:
Jul 06, 2006, 09:58 AM »
no joy for me with winrar or winxp's own zip uncompress thing, i'll PM you my email address.
cheers
0
Logged
Please consider the research and evidence of the Scholars for 9/11 Truth at
http://www.st911.org
rodsor
Jr. Member
Posts: 5
Re: [Snippet] FlexSearchForm. Modified to hide private docs and add weblink feat
«
Reply #4 on:
Jul 09, 2006, 07:30 AM »
Same error with me. I´m using 7-zip.
Logged
doze
Coding Team
Posts: 3,237
....Boom!
Re: [Snippet] FlexSearchForm. Modified to hide private docs and add weblink feat
«
Reply #5 on:
Jul 09, 2006, 04:26 PM »
Opens ok with winrar though..
Logged
MODxWiki
|| Please, list wiki worthy material
here
!
rodsor
Jr. Member
Posts: 5
Re: [Snippet] FlexSearchForm. Modified to hide private docs and add weblink feat
«
Reply #6 on:
Jul 10, 2006, 12:07 PM »
Doze, can you post the snippet code here? I still can´t open the file...
Thx.
Logged
steph
Member
Posts: 85
Re: [Snippet] FlexSearchForm. Modified to hide private docs and add weblink feat
«
Reply #7 on:
Jul 11, 2006, 03:37 AM »
Done. See original post.
Logged
Stephan Dale
http://mindspill.net/computing/cross-platform-notes/modx.html
modx(a)mindspill.net
rodsor
Jr. Member
Posts: 5
Re: [Snippet] FlexSearchForm. Modified to hide private docs and add weblink feat
«
Reply #8 on:
Jul 12, 2006, 06:15 AM »
Thanks guys. Now I can view the snippet (only the txt). But after changing the snippet code, the following error ocurrs:
Fatal error: Cannot redeclare preparesearchcontent() (previously declared in C:\Apache2\htdocs\manager\includes\document.parser.class.inc.php(705) : eval()'d code:466) in C:\Apache2\htdocs\manager\includes\document.parser.class.inc.php(705) : eval()'d code on line 475
How to correct this?
«
Last Edit: Jul 12, 2006, 06:20 AM by rodsor
»
Logged
steph
Member
Posts: 85
Re: [Snippet] FlexSearchForm. Modified to hide private docs and add weblink feat
«
Reply #9 on:
Jul 12, 2006, 06:56 AM »
Function PrepareSearchContent is being declared (aka defined) twice. Are you using two different versions of the FlexSearchForm at the same time?
Logged
Stephan Dale
http://mindspill.net/computing/cross-platform-notes/modx.html
modx(a)mindspill.net
rodsor
Jr. Member
Posts: 5
Re: [Snippet] FlexSearchForm. Modified to hide private docs and add weblink feat
«
Reply #10 on:
Jul 12, 2006, 07:26 AM »
No, I only replaced the original code of snippet with this, on original installation.
Logged
steph
Member
Posts: 85
Re: [Snippet] FlexSearchForm. Modified to hide private docs and add weblink feat
«
Reply #11 on:
Jul 12, 2006, 09:11 AM »
As mentioned in my original post I modified MadeMyDay's version, which added the PrepareSearchContent function.
Quote
Note that the code I modified was that of MadeMyDay's (posted on the MODx forums at
http://modxcms.com/forums/index.php/topic,2762.0.html
) which added support for showing an extract of the context with highlighted search terms
Perhaps you'll find an answer on that thread.
Either way, you're declaring the function twice, so look through the snippets you use to find out which ones define it.
Logged
Stephan Dale
http://mindspill.net/computing/cross-platform-notes/modx.html
modx(a)mindspill.net
steph
Member
Posts: 85
Re: [Snippet] FlexSearchForm. Modified to hide private docs and add weblink feat
«
Reply #12 on:
Feb 05, 2007, 05:39 PM »
It's been a while, but I've just hit this problem again and I know the proper solution now. I was right in saying that the snippet was being referenced twice, but that was a dumb thing to say because a search snippet is often referenced twice - perhaps once in a menu and once in the content of the results page. The solution is to check whether the function exists before declaring it. So, for every function, surround it with a function_exists call, like so:
Code:
if (!function_exists('TheFunction')) {
function TheFunction {
...
}
}
I've posted about it here too:
http://modxcms.com/forums/index.php?PHPSESSID=7cbbcac1ace4d6f9ab1b016372362893&topic=9332.msg%25msg_id%25
Also, after migrating my site to a different server, which uses a different version of PHP, I found that you can't get away with declaring the functions at the end of the file without generating the following error:
Code:
Call to undefined function
The solution seemed to be to move the function declarations to the top. Note that whilst this solved the problem, I tried rolling back to reproduce the exact error, but it still seems to work despite using the old version. I've been getting odd caching behaviour ever since migrating so who knows?!
I've updated the download links in my first post to reflect the latest version I have.
Logged
Stephan Dale
http://mindspill.net/computing/cross-platform-notes/modx.html
modx(a)mindspill.net
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ışı