Sep 06, 2008, 01:24 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
modxcms.com web
  MODxCMS.com   Forums   Help Login Register  
News:Donate to MODx: Donations
Pages: [1] 2 3   Go Down
  Print  
Author Topic: [snippet] DropMenu. Modified for weblinks and regexp on keywords/TV.  (Read 13438 times)
0 Members and 1 Guest are viewing this topic.
steph
Member
**
Posts: 85


WWW
« on: Jan 27, 2006, 06:25 AM »

17/12/2006. The minor core code mod required for this modified dropmenu to work has now been done for 0.9.5. See http://modxcms.com/forums/index.php/topic,2612.0.html

05/12/2006. This modified DropMenu snippet requires a minor change to the core code. Originally the mod was done for 0.9.1, but I've posted the version for MODx-095rc3-rev2066 on page 3 and updated the related topic referenced below.

Updated on 15/04/2006 to add new NOT join method (because it's difficult to write regular expressions that return everything not matching a pattern) and assign a css class to weblinks.

Hi all.

I've modified the DropMenu snippet to support the following:

1. Show all items regardless of whether they've been flagged to appear in the menu or not.
2. Link to a weblink's URL rather than the weblink itself.
3. Filter docs via a regular expression on their keywords.
4. Filter docs via a regular expression on a given template variable.
5. Join the results using AND, XOR, OR, NOT.
6. Assign a css class to weblinks (so they can be styled to indicate they're external links).

The new config parameters are as follows:

&showAllInMenu - [ true | false ] If true prevents docs being filtered by their 'sitemenu' flags. i.e. all appropriate docs are output regardless of whether they've been flagged to appear in the menu or not. Defaults to false.

&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.

&keywordRegexp - [ string ] A regular expression to check against the keywords. This filters out all docs other than those with a matching keyword.

&tvRegexpField - [ string ] The name of a template variable on which to apply a regular expression. The regexp is specified using the &tvRegexpString parameter.

&tvRegexpString - [ string ] A regular expression to check against the given template variable. This filters out all docs other than those with a matching TV. The TV is specified using the &tvRegexpField parameter.

&joinMethod - [ "and" | "xor" | "or" | "not" ] A string that indicates whether to join the filter results using an AND (intersection), an XOR (difference) or an OR (union). If the NOT operation is used, it returns all documents except those that were matched. Defaults to OR (union).

&weblinkClass - [ string ] CSS class for a weblink's anchor. Defaults to "weblink".

I've used this new functionality on my site http://mindspill.net to build pages of links based on the value of a "keywords" template variable. I've got several folders that store related links, like computing links or media links, then add more fine-grained categorisation by using the "keywords" TV.

My use of a "keywords" TV allows me to have admin defined keywords (via the built in keywords system) as well as user defined keywords (via the TV).

The changes to DropMenu could easily be used to create a section/category setup, where the sections are folders and categories are defined by the value of a template variable.

Note that allowing the use of Keywords and TVs with weblinks required some changes to core code, which I'll post a little later... Now posted.. http://modxcms.com/forums/index.php/topic,2612.0.html

The code can be optimised, so please let me know if you do so. Also, whilst I'm fairly sure the changes I made do not intrude on current functionality I've only tested it within the bounds of my setup.

Let me know whether you find these changes useful. Also, whether you think I should have made a new snippet rather than modify one that does a perfectly good job within it's scope. I'm not sure how the MODx and it's community prefer things to be done. Let me know.

Thanks.

Steph

P.S. Code in next post.
« Last Edit: Dec 17, 2006, 05:49 PM by steph » Logged

steph
Member
**
Posts: 85


WWW
« Reply #1 on: Jan 27, 2006, 06:28 AM »

Update 11/07/2006: Added latest version which includes parameters to set the message that displays when there are no menu items.

Code attached below.

Steph

* DropMenuMindspillDotNet.php.zip (6.64 KB - downloaded 365 times.)
* DropMenuMindspillDotNet.php.gz (6.51 KB - downloaded 420 times.)
* DropMenuMindspillDotNet.php.txt (23.42 KB - downloaded 316 times.)
« Last Edit: Jul 11, 2006, 03:56 AM by steph » Logged

rthrash
Foundation
*
Posts: 9,105



WWW
« Reply #2 on: Jan 27, 2006, 06:47 AM »

Hi steph, this is really cool and thanks for sharing. You can compress the files into a .zip archive and attach them to posts.

Personally, I think it's a great addition to DropMenu, which needs a thorough going-over again anyway... several other bugs and requests on our trakcer for the next rev anyway.

Speaking of which, can you please note this thread/request on our bugtracker as a feature request for a future version. We might need two That's how we make sure things on the forum don't slip under the radar.

You'll probably want to make two requests: one for the dropmenu snippet and one for the core code changes (which we'd love to see, too):
Quote
Note that allowing the use of Keywords and TVs with weblinks required some changes to core code, which I'll post a little later.
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.
steph
Member
**
Posts: 85


WWW
« Reply #3 on: Jan 27, 2006, 07:08 AM »

I've added the feature request to the bug tracker.

http://modxcms.com/bugs/task/236

I'll be back to post info about the core modifications, which are very basic btw.

Steph
Logged

davidm
Marketing & Design Team
*
Posts: 6,590


The best way to predict the future is to invent it


WWW
« Reply #4 on: Jan 27, 2006, 09:05 AM »

Waow very nice additions to the DropMenu, I see several possible use for this in my next projects Grin  Keywords searching will probably make a LOT of people happy ! Same for regular expressions and join querry...

I am downloading it and waiting for the code changes...
« Last Edit: Jan 27, 2006, 09:08 AM by davidm » 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.5 | 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 Smiley
steph
Member
**
Posts: 85


WWW
« Reply #5 on: Jan 27, 2006, 10:33 AM »

I've updated my first 2 posts because I noticed some of the documentation was slightly incorrect.

Steph
Logged

steph
Member
**
Posts: 85


WWW
« Reply #6 on: Jan 27, 2006, 10:38 AM »

Is there any way to update tasks on the bug tracker?

Steph
Logged

rthrash
Foundation
*
Posts: 9,105



WWW
« Reply #7 on: Jan 27, 2006, 11:51 AM »

I think just post a comment and that'll function as the same thing.
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.
steph
Member
**
Posts: 85


WWW
« Reply #8 on: Jan 28, 2006, 12:44 PM »

I've added a new post with the changes I made to /manager/actions/dynamic/mutate_content.dynamic.action.php that allowed weblinks to have META Keywords and template variables.

http://modxcms.com/forums/index.php/topic,2612.0.html

Steph
Logged

jwtyler
Member
**
Posts: 93


Hacking with minimal knowledge


WWW
« Reply #9 on: Mar 03, 2006, 11:20 AM »

Installed this snippet and updated core I get this parse error... any ideas? I really like the show menu toggle.

« MODx Parse Error »
MODx encountered the following error while attempting to parse the requested resource:
« Execution of a query to the database failed - Unknown column 'sc.here' in 'order clause' »
      SQL: SELECT DISTINCT sc.id,sc.pagetitle,sc.description,sc.isfolder,sc.parent,sc.alias,sc.longtitle,sc.menutitle,sc.hidemenu,sc.introtext,sc.content_dispo,sc.contentType,sc.type,sc.template FROM `modx`.modx_site_content sc LEFT JOIN `modx`.modx_document_groups dg on dg.document = sc.id WHERE sc.parent = '0' AND sc.published=1 AND sc.deleted=0 AND (sc.privateweb=0) ORDER BY sc.here DESC;
      [Copy SQL to ClipBoard]
 
Parser timing
  MySQL:    0.0797 s s   (41 Requests)
  PHP:    0.1814 s s   
  Total:    0.2611 s s   
Logged
steph
Member
**
Posts: 85


WWW
« Reply #10 on: Mar 03, 2006, 11:53 AM »

Hi.

I've got this message before when trying to use it alongside the unmodified dropmenu. In fact, I've got this every time I attempt to use one version of a snippet on one page and another version on another page. Not sure why. They're probably not synchronised (or whatever the alternative term is in php). Any ideas any one?

Steph
Logged

jwtyler
Member
**
Posts: 93


Hacking with minimal knowledge


WWW
« Reply #11 on: Mar 03, 2006, 12:23 PM »

Ah, thats it... Two menus... One modified one not... sigh...
Logged
Mats Wall
Member
**
Posts: 54

On leave.


« Reply #12 on: Apr 06, 2006, 07:52 AM »

Personally, I think it's a great addition to DropMenu, which needs a thorough going-over again anyway... several other bugs and requests on our trakcer for the next rev anyway.
Does this mean that these changes to DropMenu will be included in 0.9.2 ?
Logged
steph
Member
**
Posts: 85


WWW
« Reply #13 on: Apr 16, 2006, 06:38 PM »

bump. See original post.
Logged

kickass
Full Member
***
Posts: 159



WWW
« Reply #14 on: May 31, 2006, 07:47 PM »

Maybe this will help--

http://modxcms.com/forums/index.php/topic,2040.0.html
Logged

"I'd love to change the world but I can't find the source code . . ."

Custom ModX Templates
Pages: [1] 2 3   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP

Copyright © 2005-2008 MODxCMS, All rights reserved. Contact Us
Styles by ziworks.com

Powered by SMF 1.1.4 | SMF © 2005, Simple Machines LLC

Valid XHTML 1.0! Valid CSS!