Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Church site using GS
#1
http://www.sixthgrace.org/
Reply
#2
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
Code:
$pagesArray[$count]['content'] = $data->content;
and
Code:
$xml.="<content><![CDATA[".$page['content']."]]></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.

Code:
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;
        }
        usort($menu,"article_sorting");
        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?
Reply
#3
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:

Code:
/** News List on Home Page **/

function get_news_list($slug) {

  $path="data/pages/";
  $xml_path="$path$slug.xml";        
    $data='';
    $parent = '';
    
    //Parents
    if($da = @fopen($xml_path,"r"))
        {
            $data=getXML($xml_path);
            $parent= $data->parent;
            @fclose($da);
        }
        else
        {
        echo "Error: Cannot find <strong>$xml_path</strong>";
        }
        if ($parent =='')
        {
            $parent=$slug;
        }
    
    //Children
    $count=0;
  $urlArray = array();
  $morderArray = array();

  if (is_dir($path)) {
    if ($dh = opendir($path)) {
      while (($file = readdir($dh)) !== false) {
           if($file!="." AND $file!=".." AND $file!=".htaccess"){
             $xml_path="$path$file";            
             $da = @fopen($xml_path,"r");
             $data=getXML($xml_path);  
             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;
                            
                            $count++;
                        }    
                    }
                    @fclose($da);
                }
            }
            closedir($dh);
        }
    }
    //Layout
    $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.

Code:
<?php get_news_list(return_page_slug()); ?>
Reply




Users browsing this thread: 1 Guest(s)