I know what I wanted to achieve is doable with ditto, but I can’t wrap my head around it.
This is what I want to do: to filter out a very long list of addresses by cities, states with list format
<ul class="listing">
<li>name1</li>
<li>address1</li>
<li>name2</li>
<li>address2</li>
</ul>
what I want to present is, with a list of city names like so as tag cloud: Berkeley, New York, Albany, Oakland, San Jose....
when a city is clicked, take Berkeley for example, it output a list of addresses for Berkeley only. I don’t particularly want a landing page, but can live with it if that is the only way to achieve.
Note that these addresses do not appear in other parts of the site, that means it’s not a search function I am after.
Can you kindly point me to a direction with the below Ditto call as to what other favors are needed to make it happens. I was thinking I need to add filter, depth and sortby parameters, and create extra chunks for ditto templates. I was thinking a chunk that contains all addresses is enough for ditto to call and filter out but I don’t seem able to get it working.
This is the call I have right now.
[[Ditto? &parents=`16` &summarize=`16` &total=`20` &tpl=`storeList` &tagDelimiter=`, ` &tagData=`myTags` ]]
The ’&summarize=`16`’ is not needed correct? and the ’&total’ value should be increased
Thanks!
tgp
Nobody can help me??
I am getting so close, I need a pointer or two... I feel this is a threshold that is holding me back to finally ’make sense’ how Ditto works.
tgp
well... how is the data stored? one doc per address? are the address-elements stored in template variables (e.g. name, street, zip, city)? Or do you keep all these addresses in one single doc? As long as we don’t know about that, we can’t really make any helpful suggestions...
Well, if you want all addresses in one single doc, it simply won’t work.
The key to being able to filter out data - any data - is structure. What you have now, is the opposite of that. It’s just a bunch of text.
You could either store the addresses in a separate database-table and use a few custom lines of php to output a list in one single document OR use one modx doc per address in conjunction with TVs, and Ditto to filter out certain addresses according to TV values.
I think you should really read up on basics here: A database or scripting language can’t just automagically guess what you are trying to find. That’s not really MODx’s fault, it’s just the way things work. Look at any address-book type of web-app: You won’t see all items thrown into one big data-field. How is PHP (or MODx) to know which <li> item stands for street, ZIP, state or city? Where does one dataset (record) begin, and where does it end?
-
☆ A M B ☆
- 24,524 Posts
Unless you want to write a snippet that parses the document, and sucks up blocks of 3 or 4 <ul></ul> tags. You’d be better off using an XML document and parse it properly if you’re going to do it that way. Actually, that’s what XML is for.
http://il2.php.net/manual/en/ref.xml.php
http://il.php.net/simplexml (php 5 only)
There are a few nice libraries for working with this...
http://sourceforge.net/projects/phpxpath/
http://evan.wordpress.com/2006/01/17/cxml-a-fast-dependentless-xml-library-for-php/
Thanks both for the pointers.
sottwell, thanks for the links of simple XML. Will see how far I can go with this approach.
tgp