Jump to content


ContentListing


  • You cannot reply to this topic
20 replies to this topic

#1 quadratmeter

    Etomite Forum Newbie

  • Member
  • 1 posts

Posted 29 December 2005 - 10:19 PM

I have added a new snippet to the Snippet Library!

Snippet name: ContentListing
Author: quadratmeter
Version: 1.0 (Beta)
More info: View this snippet
Description:
This is a simple snippet to get all documents from the given id in a tree structure and lists them.
You can use it as sitemap or as (like the name) content listing.
The comments are in german, but i hope you'll enjoy it.


Please feel free to comment on this snippet, suggest improvements, or simply praise my work! ;)

[This is an automatically created message]

#2 mackone

    Etomite Forum Newbie

  • Member
  • 2 posts

Posted 17 March 2006 - 02:30 PM

I try to use your snippet and got this error:
Fatal error: Cannot redeclare getcontent() (previously declared in /..../index.php(484) : eval()'d code:23) in /......./index.php(484) : eval()'d code on line 58
I'm newbie in php, and don't know what other details you need to see what's wrong.
I need a little help with this one, pls

#3 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 17 March 2006 - 02:48 PM

mackone, on Mar 17 2006, 02:30 PM, said:

I try to use your snippet and got this error:
Fatal error: Cannot redeclare getcontent() (previously declared in /..../index.php(484) : eval()'d code:23) in /......./index.php(484) : eval()'d code on line 58
I'm newbie in php, and don't know what other details you need to see what's wrong.
I need a little help with this one, pls
most likely:
you have two snippets on the page, both of which have a function called getcontent.

#4 Zero0

    Etomite Forum Newbie

  • Member
  • 3 posts

Posted 18 March 2006 - 04:29 AM

mackone, on Mar 17 2006, 03:30 PM, said:

I try to use your snippet and got this error:
Fatal error: Cannot redeclare getcontent() (previously declared in /..../index.php(484) : eval()'d code:23) in /......./index.php(484) : eval()'d code on line 58

Each time the snippet runs, it tries to define the function getContent(). Just wrap the whole function in a

if (!function_exists("getContent")) { // add
function getContent($id, $etomite) { 
[...]
return $output; 
}
} // add


#5 Guest_metteehansen_*

  • Guests

Posted 29 March 2006 - 11:43 AM

I use snippet ContentListing to show a newletter every day. I use dates like: 26.03.06 and 06.05.06.
The snippets sort my documents so that the newest document is placed in the bottom and the oldest one is placed at the top. Can I change it, so that the newest one is at the top? :huh:

#6 Guest_metteehansen_*

  • Guests

Posted 29 March 2006 - 11:45 AM

I use snippet ContentListing to show a newletter every day. I use dates like: 26.03.06 and 06.05.06.
The snippets sort my documents so that the newest document is placed in the bottom and the oldest one is placed at the top. Can I change it, so that the newest one is at the top? :huh:

#7 espersen

    Etomite Forum Fan

  • Member
  • Pip
  • 144 posts

Posted 29 March 2006 - 11:59 AM

change 1 thing in this line:

$children = $etomite->getActiveChildren($id,'pagetitle','ASC','id, pagetitle, description, isfolder');

change ASC to DESC ;o)

#8 healthresource

    Etomite Forum Fan

  • Member
  • Pip
  • 63 posts

Posted 20 August 2006 - 03:31 PM

It shall be great if i can limit the no. of entries it retrieves, like say i only want latest three to be shown and similar. I plan to use it in side menu where it only lists latest three news items with no descriptino or dates and link is clickable.

Any solutions?
Thanks

#9 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 20 August 2006 - 04:05 PM

View Postniskumar, on Aug 20 2006, 11:31 AM, said:

It shall be great if i can limit the no. of entries it retrieves, like say i only want latest three to be shown and similar. I plan to use it in side menu where it only lists latest three news items with no descriptino or dates and link is clickable.

Any solutions?
Thanks
Newer releases of Etomite, Prelude Final in particular, include the $limit variable in the getActiveChildren() API function...

function getActiveChildren($id=0, $sort='menuindex', $dir='', $fields='id, pagetitle, longtitle, description, parent, alias', $limit="") {
  // returns a two dimensional array of $key=>$value data for active documents only
  // $id = id of the document whose children have been requested
  // $sort = the field to sort the result by
  // $dir = sort direction (ASC|DESC)
  // $fields = comma delimited list of fields to be returned for each record
  // $limit = maximun number of records to return (default=all)

With this new feature you can load your LIMIT clause using $limit = "5"; or $limit="$offset, $rowsPerPage";...

#10 healthresource

    Etomite Forum Fan

  • Member
  • Pip
  • 63 posts

Posted 20 August 2006 - 05:13 PM

WOW! Ralph, you really are an asset. It works. Thanks dear.

Edited by niskumar, 20 August 2006 - 05:21 PM.


#11 Christiane

    Etomite Forum Fan

  • Member
  • Pip
  • 124 posts

Posted 08 July 2009 - 10:51 AM

I need some help for this script, because i get Errors while checking the document as XHTML 1.0 Transitional:



Quote

  • Posted Image Line 934, Column 4: document type does not allow element "ul" here; assuming missing "li" start-tag <ul>
  • Posted Image Line 956, Column 5: end tag for "li" omitted, but OMITTAG NO was specified </ul>

    You may have neglected to close an element, or perhaps you meant to "self-close" an element, that is, ending it with "/>" instead of ">".
  • Posted Image Line 934: start tag was here ><ul>

The reason is lying in <li>-Tags, which are closed by this script to early. The link list is shown by way of example:

        # <ul>
        # <li><a href='Link1'>Link1</a>: Text1</li>
        # <li><a href='Link2'>Link2</a>: Text2</li>
 ->   # <li><a href='DirLink'>DirLink</a>: Directory</li>
        # <ul>
        # <li><a href='Link3'>Link3</a>: Text1</li>
        # <li><a href='Link4'>Link4</a>: Text2</li>
        # </ul>
        # </ul>
        
        
The <li> of the DirLink should be open until the second list is closed.
And with more interlacings (deeper structure) i get more errors.

Perhaps its interesting, that I've modified the Snippet in that way [ $url = $etomite->makeURL($child['id']) ] that it shows friendly URLs:
   // --------------------
  // Snippet: Basierend auf ContentListing
  // --------------------
  // Version: 1.0 Beta
  // Date: December 28th, 2005
  // philip@haeusler-av.de
  //
  // Rekursive Abtastung der Verzeichnisstruktur.
  //
  // Anpassung am 24.06.2009
  // Liv Christiane G&ouml;hner
  //
  //
  // Benutzung:
  // [[ContentListing?id=0]]
  //
  $content = "<h3>Some text... as heading</h3>";
  
  
  function getContent($id, $etomite) {   //Das ist die Rekursive Funktion
  
  $children = $etomite->getActiveChildren($id,'pagetitle','ASC','id, pagetitle, description, isfolder');
  
  $output = "<ul>";                          //Ebene erzeugen (Einrueckung)
  
    foreach ($children as $child) {            //Fuer jedes Unterobjekt, das uebergeben wurde
  
      if ($child['isfolder']==0) {             //wird ueberprueft, ob dieses ein ordner ist.
        $url = $etomite->makeURL($child['id']);
        $output .= "<li>";                     //wenn es ein Dokument ist, erfolgt diese Ausgabe:
        $output .= "<a href='".$url."'>".$child['pagetitle']."</a>";
  
        if ($child['description']!="") {
          $output .= ":
  ".$child['description']; // ist die Beschreibung leer oder gleich dem Titel, dann nicht.
        }                                           //klappt aber leider noch nicht ganz :'(
  
        $output .="</li>";
  
      } else {                                 //Wenn es ein Ordner ist, dann wird Folgendes ausgegeben:
  
        $url = $etomite->makeURL($child['id']);
        $output .= "<li>";
        $output .= "<a href='".$url."'>".$child['pagetitle']."</a>";
  
        if ($child['description']!="") {
          $output .= " - ".$child['description'];
        }
  
        $output .= "</li>";
        $output .= getContent($child['id'], $etomite); //Hier der rekursive Funktionsaufruf.
                                               //Der rekursiven Funktion werden die Kinder des Ordners uebermittelt.
      }
    }
    $output .= "</ul>";                        //Diese Ebene (Einrueckung) beenden.
  return $output;                              //Zur Rueckgabe des Generierten Baums an die untere Ebene.
  }
  
  $content .= getContent($id, $etomite); //Aufruf der rekursiven Funktion mit den Unterdokumenten der
                                               // uebergebenen $id.
  //Das $etomite muss uebergeben werden, damit die rekursive Funktion darauf zugreifen kann.
  
  return $content;                             //Ausgabe
  

How can the script be modified, that it works in the right way and passes test?

Thanks for assistance.

Edited by Christiane, 08 July 2009 - 01:04 PM.


#12 espersen

    Etomite Forum Fan

  • Member
  • Pip
  • 144 posts

Posted 08 July 2009 - 11:10 AM

Could you paste or attach the the Snippet-code here ?
It isnt available in the directory

nice - thanks

Edited by espersen, 08 July 2009 - 11:10 AM.


#13 Christiane

    Etomite Forum Fan

  • Member
  • Pip
  • 124 posts

Posted 08 July 2009 - 11:24 AM

View Postespersen, on 08 July 2009 - 11:10 AM, said:

Could you paste or attach the the Snippet-code here ?
It isnt available in the directory

nice - thanks

See above in my posting :-) .

[attached]:Just I've changed it a little bit , because backslashes seems to be deleted.

Edited by Christiane, 08 July 2009 - 11:40 AM.


#14 espersen

    Etomite Forum Fan

  • Member
  • Pip
  • 144 posts

Posted 08 July 2009 - 12:42 PM

View PostChristiane, on 08 July 2009 - 11:24 AM, said:

See above in my posting :-) .

[attached]:Just I've changed it a little bit , because backslashes seems to be deleted.

It validates when removing the <p> + </p> tags in the document from where you call the Snippets
- well it isnt the way to solve it but leads the way I think?

#15 Christiane

    Etomite Forum Fan

  • Member
  • Pip
  • 124 posts

Posted 08 July 2009 - 12:52 PM

View Postespersen, on 08 July 2009 - 12:42 PM, said:

It validates when removing the <p> + </p> tags in the document from where you call the Snippets
- well it isnt the way to solve it but leads the way I think?

No, there are no <p> + </p> tags.
The tests passes if the list is simply structured with one list, but fails, if listings are nested (a list in a list in a list ...)
Thats because the <li>-Tag before the next list isn't left open, but closed like a normal <li>:

right way:
        <ul>
    ->    <li>Search engines
            <ul>
              <li>Google</li>
              <li>AltaVista</li>
              <li>Fireball</li>
            </ul>
->      </li>
 ->      <li>Directories
            <ul>
              <li>Yahoo</li>
              <li>Web.de</li>
              <li>Dino-Online</li>
            </ul>
   ->     </li>
          <li>some others</li>
          <li>some others at all</li>
        </ul>
        


wrong way as the script is doing:
        <ul>
     ->   <li>Suchmaschinen</li>
            <ul>
              <li>Google</li>
              <li>AltaVista</li>
              <li>Fireball</li>
            </ul>
     ->   <li>Verzeichnisse</li>
            <ul>
              <li>Yahoo</li>
              <li>Web.de</li>
              <li>Dino-Online</li>
            </ul>
          <li>Was anderes</li>
          <li>Noch was anderes</li>
        </ul>
        
        
        

Edited by Christiane, 08 July 2009 - 01:03 PM.


#16 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 08 July 2009 - 01:00 PM

The proper nesting code is used in several other menu snippets... Take a look at either menu or site map snippets for ideas on how to fix the problem - or just use one of those that works...

#17 Christiane

    Etomite Forum Fan

  • Member
  • Pip
  • 124 posts

Posted 08 July 2009 - 01:21 PM

View PostRalph, on 08 July 2009 - 01:00 PM, said:

The proper nesting code is used in several other menu snippets... Take a look at either menu or site map snippets for ideas on how to fix the problem - or just use one of those that works...

To shorten the way, is it possible that you name me a snippet with a similar look? Many thanks.

#18 Christiane

    Etomite Forum Fan

  • Member
  • Pip
  • 124 posts

Posted 08 July 2009 - 01:28 PM

View PostChristiane, on 08 July 2009 - 01:21 PM, said:

To shorten the way, is it possible that you name me a snippet with a similar look? Many thanks.

I found some: authListSiteMap Thanks for the hint.

#19 espersen

    Etomite Forum Fan

  • Member
  • Pip
  • 144 posts

Posted 08 July 2009 - 03:13 PM

View PostChristiane, on 08 July 2009 - 01:28 PM, said:

I found some: authListSiteMap Thanks for the hint.

Maybe RecentPages could be useful too.
RecentPages

#20 Christiane

    Etomite Forum Fan

  • Member
  • Pip
  • 124 posts

Posted 08 July 2009 - 04:20 PM

View Postespersen, on 08 July 2009 - 03:13 PM, said:

Maybe RecentPages could be useful too.
RecentPages

I cann't find the code: [#10173] We could not find the attachment you were attempting to view.
Can you post it?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users