Topic: [snippet] DropMenu. Modified for weblinks and regexp on keywords/TV.  (Read 20014 times)

Pages: [1] 2 3   Go Down

#1: 27-Jan-2006, 06:25 AM

steph
Posts: 86

WWW
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: 17-Dec-2006, 05:49 PM by steph »

#2: 27-Jan-2006, 06:28 AM

steph
Posts: 86

WWW
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 499 times.)
* DropMenuMindspillDotNet.php.gz (6.51 KB - downloaded 552 times.)
* DropMenuMindspillDotNet.php.txt (23.42 KB - downloaded 448 times.)
« Last Edit: 11-Jul-2006, 03:56 AM by steph »

#3: 27-Jan-2006, 06:47 AM

Foundation

rthrash
Posts: 11,352

WWW
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.
MODx is a content managmeent framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Please help us help you when asking for assistance and read the wiki. Searching the forums from the top level helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.

#4: 27-Jan-2006, 07:08 AM

steph
Posts: 86

WWW
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

#5: 27-Jan-2006, 09:05 AM

Marketing & Design Team

davidm
MODx evangelist
Posts: 7,073

The best way to predict the future is to invent it

WWW
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: 27-Jan-2006, 09:08 AM by davidm »
.: nodeo.net : Pour un web libre, moderne et ouvert ! :: david-molliere.net : Suivez en "live" mes expérimentations et billets sur les CMS et autres applications web :.

*** 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.67 - PHP 5.2.8 | Debian 4.0 (Etch)

Réalisations sous MODx : | pargade-notaires.fr | soleil.info | gican.asso.fr | michelez-notaires.com | amadom.gerondicap.com | jocelyne-violet.net

#6: 27-Jan-2006, 10:33 AM

steph
Posts: 86

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

Steph

#7: 27-Jan-2006, 10:38 AM

steph
Posts: 86

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

Steph

#8: 27-Jan-2006, 11:51 AM

Foundation

rthrash
Posts: 11,352

WWW
I think just post a comment and that'll function as the same thing.
MODx is a content managmeent framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Please help us help you when asking for assistance and read the wiki. Searching the forums from the top level helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.

#9: 28-Jan-2006, 12:44 PM

steph
Posts: 86

WWW
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

#10: 3-Mar-2006, 11:20 AM

jwtyler
Posts: 93

Hacking with minimal knowledge

WWW
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   

#11: 3-Mar-2006, 11:53 AM

steph
Posts: 86

WWW
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

#12: 3-Mar-2006, 12:23 PM

jwtyler
Posts: 93

Hacking with minimal knowledge

WWW
Ah, thats it... Two menus... One modified one not... sigh...

#13: 6-Apr-2006, 07:52 AM

Mats Wall
Posts: 54

On leave.

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 ?

#14: 16-Apr-2006, 06:38 PM

steph
Posts: 86

WWW
bump. See original post.

#15: 31-May-2006, 07:47 PM

kickass
Posts: 160

WWW
Maybe this will help--

http://modxcms.com/forums/index.php/topic,2040.0.html
"I'd love to change the world but I can't find the source code . . ."

Custom ModX Templates

#16: 10-Jul-2006, 03:08 PM

Testers

Soda
Posts: 415

Daddy !

WWW
Hello
I'm trying the modified DropMenu that seems very good but I have error (the one with the two version of snippet is ok)


I've the patched core file.
I have that call in my template for the principal menu
  [[DropMenu2? &menuName=`TopMenu` &startDoc=`0` &levelLimit=`1` &topnavClass=`menu` &subnavClass=`sousmenu` &titleOfLinks=`longtitle`]]

and this in my siteplan page:

[[DropMenu2? &showDescription=`1` &useCategoryFolders=`true` &showAllInMenu=`false`]]

and I have this error:
Code:
« MODx Parse Error »
MODx encountered the following error while attempting to parse the requested resource:
« PHP Parse Error »
 
PHP error debug
  Error: Missing argument 28 for makemap()
  Error type/ Nr.: Warning - 2
  File: /home/dpsit/public_html/manager/includes/document.parser.class.inc.php(705) : eval()'d code
  Line: 249
 

I hoppe I can use this cool snippet, and think it will be a good thing to implement it in future version of MODx.
« Last Edit: 10-Jul-2006, 03:30 PM by Soda »
MODx Sites & Prestations: http://dp-site.fr   [Last MODx Site]
MODx Repository: [HOME]  [MetaTagsExtra] / Current Dev: [xFDM]

#17: 11-Jul-2006, 03:51 AM

steph
Posts: 86

WWW
So there's a missing arguement to the makemap function. I do vaguely recall forgetting to update one of the makemap calls in the past, but I corrected it fairly quickly. Do you have the latest version of the code? - I've done a comparison with the version I use and the makemap calls all look fine.

Steph

#18: 11-Jul-2006, 03:57 AM

steph
Posts: 86

WWW
Actually, I've update the original post to use the latest version I have.

#19: 11-Jul-2006, 08:45 AM

Testers

Soda
Posts: 415

Daddy !

WWW
Hello,
Thanks, for your answer, it works fine now, I'm trying to play with it.
Why don't put it in the repository, in the forum it is hard to find something.
Perhaps you can give somes examples of use, I don't understand the use of keywordRegexp.
 (I know I ask a lot of things Smiley)
« Last Edit: 11-Jul-2006, 09:22 AM by Soda »
MODx Sites & Prestations: http://dp-site.fr   [Last MODx Site]
MODx Repository: [HOME]  [MetaTagsExtra] / Current Dev: [xFDM]

#20: 11-Jul-2006, 09:16 AM

steph
Posts: 86

WWW
I haven't added it to the repository because it's a modification of someone elses snippet (which also require mods to the core code). I assumed that the repository was for new snippets rather than hacks.

Official MODx people... Should I put this in the repository?

Anyway, finger's crossed the regexp stuff will be in the next version of modx.

Steph
Pages: [1] 2 3   Go Up
0 Members and 1 Guest are viewing this topic.