The following warnings occurred:
Warning [2] Undefined array key "threadviews_countguests" - Line: 745 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php 745 errorHandler->error_callback
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/inc/functions_post.php 830 postParser->parse_message
/showthread.php 916 build_postbit
Warning [2] Undefined property: MyLanguage::$thread_modes - Line: 46 - File: showthread.php(1650) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php(1650) : eval()'d code 46 errorHandler->error_callback
/showthread.php 1650 eval




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Church site using GS
#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


Messages In This Thread
Church site using GS - by cameron - 2010-07-01, 00:02:50
Church site using GS - by zajca - 2010-07-02, 06:10:32
Church site using GS - by cameron - 2010-07-02, 11:50:13



Users browsing this thread: 1 Guest(s)