May 11, 2008, 07:15 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  
Pages: [1] 2 3 ... 6   Go Down
  Print  
Author Topic: Ditto 1.0  (Read 36663 times)
0 Members and 1 Guest are viewing this topic.
Mark
Moderator
*
Posts: 3,191


Ditto Developer


WWW
« on: May 12, 2006, 09:14 PM »



Announcing Ditto: the nimbler, faster, better-named and even more flexible offspring of NewsListing.
 
The fact is, Newslisting is useful for much more than summarizing and building archives of news articles. Coupled with the fact that a cornerstone MODx philosophy focuses on flexibility, and "News" seemed to syntactically restrictive. And boring.
 
Blogs... PodCasts... Press Release archives... File Download repositories... FAQs... Executive Bio listings...
 
Ditto now takes advantage of an external class, language files to work with multi-language installs, and uses templates extensively for the ultimate in output formatting flexibility and control. And while it has more than 40 configurable parameters in it's current implementation, you only need [[Ditto]] for great results (although telling it explicitly where to start probably wouldn't hurt Wink ).

Amongst the many cool things under Ditto's able and refined domain:
  • &mode parameter can disable sanity checks on variables and increase speed for production sites.
  • JSON format for AJAX applications
  • Access individual posts in templates via [+item[ # ]+] placeholders  (replacing ' # ' with actual integers).
  • Stop guessing with non-abbreviated parameter names in CamelCase convention.
  • Updated documentation and full parameter and placeholder lists.
  • xHTML Strict month-based archive output which uses templates for formatting.
  • Extensive sorting and filtering based on TVs
  • And the obligatory, "much, much more..."

Download:

Logged

mjarecki
Jr. Member
*
Posts: 35


« Reply #1 on: May 12, 2006, 10:29 PM »

Great update!

However, I still have no idea how to use &filter. I really want to be able to add tags to my documents and categorise them. But I still get the message 'No entries found.'. Sorry to be a pain about this, but it is the only thing stopping me putting my site up at the moment.

I have a series of documents with a TV called 'Category'. I've put some arbitrary words in the TV to act as my tag - the words 'red' and 'blue'.

I have a document, the Blue Archive page which acts as a listing of all documents with the word 'blue' in their Category TV, with the following in my Document Content:

Code:
[!Ditto? &startID=`41,42` &summarize=`4` &sortDir=`ASC` &tpl=`HomeSmall` &truncText=`More` &paginate=`1` &increment=`4` &filter=`tvCategory,blue,1` !] [+previous+][+pages+]{+next+]

Obviously, I'm not using the call correctly, but what am I doing? I've tried heaps of combinations with little success. I always get 'No entries found' when i know they exist. Please help!

Again, thanks for a wonderful snippet Mark!

mark j
Logged
Mark
Moderator
*
Posts: 3,191


Ditto Developer


WWW
« Reply #2 on: May 13, 2006, 12:25 AM »

You are using the call correctly, but as I stated in the NewsListing thread, I am still working on figuring out how to handle tagging. The call you are using is saying that if the tv Category is equal to blue (not containing blue) then only show it.
Logged

Rachael
Jr. Member
*
Posts: 28



« Reply #3 on: May 14, 2006, 11:55 AM »

Brilliant. Arrived just as I needed it.

Two little problems. First - is dateFormat the same as in NewsListing?
I have
Code:
[[Ditto? &startID=`7,30,28` &filter=`tvfrontpage,Yes,=` &hiddenTVs=`frontpage,section` &tpl=`NewsItem`&summarize=`5` &displayArchive=`0` &sortBy=`editedon` &dateFormat=`%A %d %B %Y %H:%M`]]
but it seems to ignore whatever I set for dateFormat.

Second - 'section' is a TV with default value @INHERIT default. I have different section of the tree and style them differently in css, which works fine. However when I use the TV in Ditto template as [+tvsection+] it always has vaue 'default' unless I set it explicitly for that document. Should it be able to handle inherited TV values?
Logged
Mark
Moderator
*
Posts: 3,191


Ditto Developer


WWW
« Reply #4 on: May 14, 2006, 06:13 PM »

Ok, faulty search and replace.

Replace this:

Code:
$dateFormat = isset($dateFormatformat)? $dateFormatformat : $_lang['date_format'];
    // format for the summary post date format

With this:

Code:
$dateFormat = isset($dateFormat)? $dateFormat : $_lang['date_format'];
    // format for the summary post date format
Logged

Windows X
Jr. Member
*
Posts: 5

I love MODx!


« Reply #5 on: May 14, 2006, 09:20 PM »

Tried, nice updates for giving more flexible and support. However, it seems some stuffs aren't in the right shape like search, [!snippet!] function, data query,  multiple startid, etc. It would be great if you can sort out all of these and make shortening [+title+] possible. I mod newslisting to support shortening title feature like summary for my sidebar. I don't know why I can't do the same to Ditto. It would be good if you add trunc... features from summary to title also.
Logged
Mark
Moderator
*
Posts: 3,191


Ditto Developer


WWW
« Reply #6 on: May 14, 2006, 09:54 PM »

Windows X, I don't know what you are talking about. Ditto works fine with [!Ditto!] and [[Ditto]] and multiple startID's work fine as well. Additionally, you can you any field you wish such as [+menutitle+] for shortened titles.
Logged

OncleBen31
Sr. Member
****
Posts: 283


I believe in MODx!


WWW
« Reply #7 on: May 15, 2006, 01:46 AM »

I think there is the same problem with the "descendentDepth" parameter :

Find the code :
Code:
$descendentDepth = (isset($levelLimit))? $levelLimit : 0;
// number of levels deep to go, 0 indicates infinite
And replace by :
Code:
$descendentDepth = (isset($descendentDepth))? $descendentDepth : 0;
// number of levels deep to go, 0 indicates infinite

Mark do you confirm my patch ?

Edited :
I found another stange behaviour. When I delete a document but don't empty the trash, document are still displayed with Ditto Huh
« Last Edit: May 15, 2006, 01:50 AM by OncleBen31 » Logged
mjarecki
Jr. Member
*
Posts: 35


« Reply #8 on: May 15, 2006, 04:01 AM »

Hi Mark,

I've been playing with trying to get the tag/categories to work as I'd described earlier. I've found that if you replace (in the ditto.class.inc.php):

Code:
case 1 :
if (!isset ($r[$filterKey]) || $r[$filterKey]!=$filterName) $unset=1;

WITH

Code:
case 1 :
if (!isset ($r[$filterKey]) || ereg($filterName,$r[$filterKey]) != '1') $unset=1;

You can filter by a value in a TV, using a call such as:

Code:
[!Ditto? &startID=`41,42` &summarize=`4`&sortDir=`ASC` &tpl=`HomeSmall` &dateFormat=`%d %B %y` &truncText=`More` &paginate=`1` &increment=`4` &filter=`tvCategory,Travel,1` !]

Which shows all documents that match the word 'Travel' in the Category TV. Currently I have 3 documents with 'Photography, Travel' in my Category TV - and it works.

However, I've noticed that unless I have a chunk template (in this case 'Homesmall') with the TV declared in a placeholder (in this case [+tvCategory+]) that TV is not being filtered and is not in the $resource array. I've tried to put &hiddenTVs=`Category` in the call but that did nothing.

To see what was going on, I used the following in the ditto.class.inc.php:

Code:
case 1 :
print_r($resource[$k]);


I'm not yet sure how to get the $resource array to include my TV (category in my case) without declaring it in my Chunk with [+tvCategory+]. Like I said, I've tried &hiddenTVs=`Category` to no avail.

Cheers

mark j
« Last Edit: May 15, 2006, 04:04 AM by mjarecki » Logged
zenmaster
Full Member
***
Posts: 138


WWW
« Reply #9 on: May 15, 2006, 12:48 PM »

I am experiencing a slight problem.

I have a snippet
Code:
<h2>features</h2>
<div class="box">
  [!Ditto10? &startID=`2` &summarize=`3` &total=`3` &truncSplit=`0` &tpl=`NewsHeadlines`!]
<a class="small" href="features.html">More Features</a>
</div>
<h2>reviews</h2>
<div class="box">
  [!Ditto10? &startID=`3` &summarize=`3` &total=`3` &truncSplit=`0` &tpl=`NewsHeadlines`!]
<a class="small" href="reviews.html">More Reviews</a>
</div>
<h2>news</h2>
<div class="box">
  [!Ditto10? &startID=`4` &summarize=`3` &total=`3` &truncSplit=`0`  &tpl=`NewsHeadlines`!]
<a class="small" href="news.html">More News</a>
</div>

The template is
Code:
<div class="newsheadline">
  <p>
    <a href="[~[+id+]~]"><img src="[+tvStoryImage+]" alt="link to story"/><strong>[+title+]:</strong> [+summary+]</a>
</p>
</div>

This should produce 3 boxes, each containing the first 3 summaries from their respective categories. However, only the first displays as it should, the others show no results. I have varied the order in which they are displayed and whichever comes first is OK, the subsequent ones are not. I have also set them to all display the same startid - in this case the display is as expected.

This is the HTML generated
Code:
<div id="block_1">

  <div class="newsheadlines">
 
    <h2>features</h2>
    <div class="box">

      <div class="newsheadline">
        <p>
          <a href="features/one-life-stand.html">
            Image and text .....
          </a>
        </p>
      </div>  <!-- newsheadline -->

      <div class="newsheadline">
        <p>
          <a href="features/one-life-stand2.html">
            Image and text .....
          </a>
        </p>
      </div>  <!-- newsheadline -->

      <div class="newsheadline">
        <p>
          <a href="features.html">
              Image and text .....
          </a>
        </p>
      </div>  <!-- newsheadline -->
      <a class="small" href="/one-life-stand3.html.html">More Features</a>
    </div>  <!-- box -->

    <h2>reviews</h2>
    <div class="box">
      <div class="newsheadline">
        <p>
          <a href="[~~]"><img src="" alt="link to story"/><strong>:</strong> </a>
        </p>
      </div>  <!-- newsheadline -->
      <a class="small" href="reviews.html">More Reviews</a>
    </div>  <!-- box -->

    <h2>news</h2>
    <div class="box">
      <div class="newsheadline">
        <p>
          <a href="[~~]"><img src="" alt="link to story"/><strong>:</strong> </a>
        </p>
      </div>  <!-- newsheadline -->
      <a class="small" href="news.html">More News</a>
    </div>  <!-- box -->
  </div>  <!-- newsheadlines -->
</div> <!-- block 1 -->

I have FURLs turned on to use entire path and allow duplicate entries.

Any ideas what might be wrong?

Thanks.
Logged
Mark
Moderator
*
Posts: 3,191


Ditto Developer


WWW
« Reply #10 on: May 15, 2006, 02:22 PM »

Laughs! I figured out the problem... simple things simple things......

Look for 1.0.1 later today which will fix all these things and add one more new feature--- tagging.
Logged

Mark
Moderator
*
Posts: 3,191


Ditto Developer


WWW
« Reply #11 on: May 15, 2006, 02:26 PM »

Ok, here is the fix for those who cannot wait.

Replace:
Code:
} else if(file_exists($filevalue) &&  $filename == "language") {
include_once($filevalue);

with

Code:
} else if(file_exists($filevalue) &&  $filename == "language") {
include($filevalue);

That fixs things for allowing multiple calls.
Logged

The Man Can!
Support Subscriber
*
Posts: 243



WWW
« Reply #12 on: May 15, 2006, 03:56 PM »

Great snippet! But has anybody noticed that the dates in the archive display seem to be a little off?

For instance, if I set sortBy=`pub_date`, the archive still displays the createdon date.  If I set the archiveDateType=`pub_date` it displays the correct dates, but does not categorize them by month properly, so articles posted in March still show up as sub-items of May.

Check an example: http://sp.themancan.com/41/articles.html. The top is Ditto, the bottom is NewsListing. Ditto has the last article under May when it should be under March.

Is this the intended behaviour or a bug?  Seems like it'd be nice to have the option for sortBy and archiveDateType to be different, but that dateFormatType and archiveDateType should inherit the sortBy value if not otherwise declared.

Great snippet though.  Love the customizability.
-Brett
Logged

Need MODx Ecommerce? Try FoxyCart!
zenmaster
Full Member
***
Posts: 138


WWW
« Reply #13 on: May 16, 2006, 07:26 AM »

That fixs things for allowing multiple calls.

It certainly does - though, for the life of me, I cannot see why Huh!

Thanks, Mark.
Logged
Mark
Moderator
*
Posts: 3,191


Ditto Developer


WWW
« Reply #14 on: May 16, 2006, 02:10 PM »

@The Man Can! : The first part of what you describe is an intentional feature. The manager only sets published_on and fields like it if the value is set. By default, the values are 0. Since that messes up sorting, an inline SQL if is used to swap out createdon for published_on if published_on is not set. That way it still gets sorted instead of Ditto freaking out. For you other issue, use both sortBy=`pub_date` and archiveDateType=`pub_date` in the same call. That should fix things.

@Zenmaster: I've got a pretty good idea but am not 100% sure. I believe since all the lang file does is set variables if it is kept in the system memory (include_once) it only sets the variables the first time it is run. But, when it is called each time (include) the variables get set every time. Make sense?
Logged

Pages: [1] 2 3 ... 6   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!