Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Read More - News Manager
#1
Hello!

I want to add a read more button to news manager.

I can create function to edit and save short and full text but i cant make the more button (link) to show the full article

Code:
function show_articles($n) {
  $articles = get_articles();
  if (isset($n) && $n > 0) {
    $index = (isset($_GET['page'])) ? $_GET['page'] : 0;
    $pages = array_chunk($articles, $n);
    $articles = $pages[$index];
  }
  foreach ($articles as $article) {
    $id = basename($article, ".xml");
    show_single($id);
    
?>
   <a href="WHAT TO PUT HERE?">more</a>
    <?php
    
  }
  if (isset($n))
    show_navigation($index, sizeof($pages));
}

I dont know what to put as link because getsimple uses index.php?id=pageid and i cant send variables like index.php?id=news&postid=$id
how do i do that? so a function can show the full article
Code:
$id= $_GET["postid"]

function show_full($id) {
  $file = GSDATANEWSPATH . $id . '.xml';
  $data = getXML($file);
  if (!empty($data)) {
    $date = $data->date;
    $title = stripslashes(htmlspecialchars_decode($data->title, ENT_QUOTES));
    $short = stripslashes(htmlspecialchars_decode($data->short, ENT_QUOTES));
    $content = stripslashes(htmlspecialchars_decode($data->content, ENT_QUOTES));

    
    ?>
    <div class="article">
      <h3 class="article_title"><?php echo $title; ?></h3>
      <p class="article_date">Posted on: <?php echo $date; ?></p>
      <div class="article_content"><?php echo $short; ?></div>
    <div class="article_content"><?php echo $content; ?></div>
    </div>
    <?php
  } else {
    echo '<p>The requested article does not exist.</p>';
  }
}
Reply
#2
Hi, I never used news manager but I think I can help you.
I did not make a plugin. I just modified all of my files Sad
Here is what I did. You can make it a function.
Code:
<?php get_page_content(); ?>
                
                <?php
                
                $page = return_page_slug();
                
                if ($page == "index")
                {
                foreach(menu_data() as $menu)
                {
                if ($menu["menu_text"] != "Home")
                {
                echo "<br /><br />";
                $pubdate = date('l F dS Y \a\t: h:i a',strtotime($menu["pub_date"]));
                echo "<a href=",$menu["url"],">", $menu["title"],"</a><br />",$menu["content"],"<br />Posted on: ",$pubdate,"<br />";
                }
            
                }
                
                }
                ?>

I modified my menu_data to include the content so just remove that.
Here is how you create the links echo "<a href=",$menu["url"],">", $menu["title"],"</a>
Let me try to clean up for what you need
Code:
<?php
                foreach(menu_data() as $menu)
                {
                echo "<a href=",$menu["url"],">", $menu["title"],"</a><br /><br />";
                }
                ?>
Reply
#3
How do you do this?
Reply




Users browsing this thread: 1 Guest(s)