GetSimple Support Forum

Full Version: Church site using GS
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi man,
i'am wondering how did you done "events and announcements" page.
I'am trying to do same thing. I try to change multilevel menu, but i stuck.

i've add
$pagesArray[$count]['content'] = $data->content;

note: I'am not good with PHP

I have few problems:
1. I'am not getting data from all pages (i'am getting content and pubDate only from one page and from others only title)
2. How can I get only few first characters from content.

function page_article($a='') {
        if (!isset($a) || $a == '' || empty($a)) { $a = return_page_slug(); }
        $data = simplexml_load_string(ye_olde_data());
        $menu = $data->xpath('//*[parent="first-article"]');  /* Show only pages with this parent */
        function article_sorting($a, $b) {
            $c1=strcmp($a->menuOrder, $b->menuOrder);
            if ($c1!=0) return $c1;
            $c2=strcmp(strtolower(($a->menu!=""?$a->menu:$a->pubDate)), strtolower(($b->menu!=""?$b->menu:$b->pubDate)));
            if ($c2!=0) return $c2;
            $c3=strcmp($a->slug, $b->slug);
            if ($c3!=0) return $c3;
        if (count($menu) > 0) {
            echo '<ul class="menu">';
            foreach ($menu as $link) {
                $prnt = count($data->xpath('//item[slug="'.$a.'"][parent="'.$link->slug.'"]'));
                echo '<li'.("$link->slug"==$a?' class="active"':($prnt>0?' class="parent"':'')).'><a href="'.$link->url.'">'.($link->menu!=""?$link->menu:$link->title).'</a>';
                echo '<br />';
                echo ''.($link->menu!=""?$link->menu:$link->pubDate).'';
                echo '<br /> <br />';
                echo ''.($link->menu!=""?$link->menu:$link->content).'';                
                echo '</li>';
                echo '<br /> <br />';
            echo '</ul>';

Could you please help me?
Here is what I used. I found this somewhere in this forum, and modified it to my needs.

First, you need to create a parent page. Mine was the homepage, so I made all the pages I wanted to be "News and Announcements" a child of "index".

Add this to your theme's function.php file:

/** News List on Home Page **/

function get_news_list($slug) {

    $parent = '';
    if($da = @fopen($xml_path,"r"))
            $parent= $data->parent;
        echo "Error: Cannot find <strong>$xml_path</strong>";
        if ($parent =='')
  $urlArray = array();
  $morderArray = array();

  if (is_dir($path)) {
    if ($dh = opendir($path)) {
      while (($file = readdir($dh)) !== false) {
           if($file!="." AND $file!=".." AND $file!=".htaccess"){
             $da = @fopen($xml_path,"r");
             if ($data->parent != ''){
                        if (strcasecmp($data->parent, $parent) == 0) {
                            $morderArray[$count]['menuorder'] = $data->menuOrder;            
                            $morderArray[$count]['count'] = $count;
                 $urlArray[$count]['url'] = $data->url;
                            $urlArray[$count]['title'] = $data->title;
                            $urlArray[$count]['content'] = $data->content;
    $output ='<div>';
    foreach ($morderArray as $key => $val) {
        $n= $morderArray[$key]['count'];
        $output .= '<dl class="news-list">';
        $output .= '<dt><a href="index.php?id='.$urlArray[$n]['url'].'">'.$urlArray[$n]['title'].'</a></dt>';
        $output    .= '<dd>'._substr(htmlspecialchars_decode($urlArray[$n]['content']),75).'</dd>';
        $output .=    '<dd><a class="readmore" href="index.php?id='.$urlArray[$n]['url'].'">read more</a></dd>';
        $output    .= '</dl>';
    $output .= '</div>';
    echo $output;

Then create a new template for that page you would like to display the stories on and add this wherever you would like the list to be displayed.

<?php get_news_list(return_page_slug()); ?>