• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

AAC ZNOTE ACC - READ MORE IN NEWS

You've got two main options really:

1) The slower but easier way is to fetch pretty much all news items, and only show the first 5 or so, and then add an event listener in javascript to reveal the next 5 on each click.

2) The faster but harder way is to make a new php file that fetches additional news items from the last news item index. You will need to make an Ajax call on the click event listener in javascript and render the results on success.
 
You've got two main options really:

1) The slower but easier way is to fetch pretty much all news items, and only show the first 5 or so, and then add an event listener in javascript to reveal the next 5 on each click.

2) The faster but harder way is to make a new php file that fetches additional news items from the last news item index. You will need to make an Ajax call on the click event listener in javascript and render the results on success.

Okay, and how to make the topic of the news on top and the content hidden, expanding after clicking?
[THIS IS @Znote ACC LAST NEWS PAGE]

1656069707255.png
 
Create a click listener on the topic header div. And then toggle display block or display none on the news content div.

Hard to explain if you don't know how to code. Paste the code block here.
 
Create a click listener on the topic header div. And then toggle display block or display none on the news content div.

Hard to explain if you don't know how to code. Paste the code block here.
Could you change this for me? This is code (last new).

PHP:
<?php
if ($config['UseChangelogTicker']) {
    //////////////////////
    // Changelog ticker //
    // Load from cache
    $changelogCache = new Cache('engine/cache/changelog');
    $changelogs = $changelogCache->load();

    if (isset($changelogs) && !empty($changelogs) && $changelogs !== false) {
        ?><hr>
        <div class="panel panel-default">
        <div class="panel-heading">
        <table id="changelogTable">
            <tr class="yellow">
                <td colspan="2">Latest Changelog Updates (<a href="changelog.php" style="color: darkorange;">Click here to see full changelog</a>)</td>
            </tr>
            <?php
            for ($i = 0; $i < count($changelogs) && $i < 5; $i++) {
                ?>
                <tr>
                    <td><?php echo getClock($changelogs[$i]['time'], true, true); ?></td>
                    <td><?php echo $changelogs[$i]['text']; ?></td>
                </tr>
                <?php
            }
            ?>
        </table></div></div>
        <?php
    } else echo "";
}
$cache = new Cache('engine/cache/news');
if ($cache->hasExpired()) {
    $news = fetchAllNews();
    
    $cache->setContent($news);
    $cache->save();
} else {
    $news = $cache->load();
}

// Design and present the list
if ($news) {
    function TransformToBBCode($string) {
        $tags = array(
            '[center]{$1}[/center]' => '<center>$1</center>',
            '[b]{$1}[/b]' => '<b>$1</b>',
            '[size={$1}]{$2}[/size]' => '<font size="$1">$2</font>',
            '[img]{$1}[/img]'    => '<a href="$1" target="_BLANK"><img src="$1" alt="image" style="width: 100%"></a>',
            '[link]{$1}[/link]'    => '<a href="$1">$1</a>',
            '[link={$1}]{$2}[/link]'   => '<a href="$1" target="_BLANK">$2</a>',
            '[color={$1}]{$2}[/color]' => '<font color="$1">$2</font>',
            '[*]{$1}[/*]' => '<li>$1</li>',
        );

        foreach ($tags as $tag => $value) {
            $code = preg_replace('/placeholder([0-9]+)/', '(.*?)', preg_quote(preg_replace('/\{\$([0-9]+)\}/', 'placeholder$1', $tag), '/'));
            $string = preg_replace('/'.$code.'/i', $value, $string);
        }

        return $string;
    }
    foreach ($news as $n) {
        ?>

        <div class="panel panel-default">
        
            <div class="panel-heading"><img style="margin-top: 0px; margin-left: 0px;" img="" id="Monster" src="layout\images\news2.gif"> <i class="status-online"></i> <b><font color="#dedede"> <?php echo TransformToBBCode($n['title']); ?></b></font> <i class="status-online"></i>  <?php echo getClock($n['date'], true); ?></div>
            <div class="panel-body">
            
                <?php echo TransformToBBCode(nl2br($n['text'])); ?>
            </div>
      </div>
      
      
      <br>
    
        <?php
    }
}
?>
 
are you using jQuery?

If so, just add this to your js file:
JavaScript:
$(document).on("click", ".panel-heading", function(){
    $(this).siblings(".panel-body").toggle();
});

or add it as a script tag in your news php file:
JavaScript:
<?php
if ($config['UseChangelogTicker']) {
    //////////////////////
    // Changelog ticker //
    // Load from cache
    $changelogCache = new Cache('engine/cache/changelog');
    $changelogs = $changelogCache->load();

    if (isset($changelogs) && !empty($changelogs) && $changelogs !== false) {
        ?><hr>
        <div class="panel panel-default">
        <div class="panel-heading">
        <table id="changelogTable">
            <tr class="yellow">
                <td colspan="2">Latest Changelog Updates (<a href="changelog.php" style="color: darkorange;">Click here to see full changelog</a>)</td>
            </tr>
            <?php
            for ($i = 0; $i < count($changelogs) && $i < 5; $i++) {
                ?>
                <tr>
                    <td><?php echo getClock($changelogs[$i]['time'], true, true); ?></td>
                    <td><?php echo $changelogs[$i]['text']; ?></td>
                </tr>
                <?php
            }
            ?>
        </table></div></div>
        <?php
    } else echo "";
}
$cache = new Cache('engine/cache/news');
if ($cache->hasExpired()) {
    $news = fetchAllNews();
    
    $cache->setContent($news);
    $cache->save();
} else {
    $news = $cache->load();
}

// Design and present the list
if ($news) {
    function TransformToBBCode($string) {
        $tags = array(
            '[center]{$1}[/center]' => '<center>$1</center>',
            '[b]{$1}[/b]' => '<b>$1</b>',
            '[size={$1}]{$2}[/size]' => '<font size="$1">$2</font>',
            '[img]{$1}[/img]'    => '<a href="$1" target="_BLANK"><img src="$1" alt="image" style="width: 100%"></a>',
            '[link]{$1}[/link]'    => '<a href="$1">$1</a>',
            '[link={$1}]{$2}[/link]'   => '<a href="$1" target="_BLANK">$2</a>',
            '[color={$1}]{$2}[/color]' => '<font color="$1">$2</font>',
            '[*]{$1}[/*]' => '<li>$1</li>',
        );

        foreach ($tags as $tag => $value) {
            $code = preg_replace('/placeholder([0-9]+)/', '(.*?)', preg_quote(preg_replace('/\{\$([0-9]+)\}/', 'placeholder$1', $tag), '/'));
            $string = preg_replace('/'.$code.'/i', $value, $string);
        }

        return $string;
    }
    foreach ($news as $n) {
        ?>

        <div class="panel panel-default">
        
            <div class="panel-heading"><img style="margin-top: 0px; margin-left: 0px;" img="" id="Monster" src="layout\images\news2.gif"> <i class="status-online"></i> <b><font color="#dedede"> <?php echo TransformToBBCode($n['title']); ?></b></font> <i class="status-online"></i>  <?php echo getClock($n['date'], true); ?></div>
            <div class="panel-body">
            
                <?php echo TransformToBBCode(nl2br($n['text'])); ?>
            </div>
      </div>
      
      
      <br>
    
        <?php
    }
    echo '
    <script type="text/javascript">
        $(document).ready(function(){
            $(document).on("click", ".panel-heading", function(){
                $(this).siblings(".panel-body").toggle();
            });
        });
    </script>
    ';
}
?>
 
Last edited by a moderator:
are you using jQuery?

If so, just add this to your js file:
JavaScript:
$(document).on("click", ".panel-heading", function(){
    $(this).siblings(".panel-body").toggle();
});

or add it as a script tag in your news php file:
JavaScript:
<?php
if ($config['UseChangelogTicker']) {
    //////////////////////
    // Changelog ticker //
    // Load from cache
    $changelogCache = new Cache('engine/cache/changelog');
    $changelogs = $changelogCache->load();

    if (isset($changelogs) && !empty($changelogs) && $changelogs !== false) {
        ?><hr>
        <div class="panel panel-default">
        <div class="panel-heading">
        <table id="changelogTable">
            <tr class="yellow">
                <td colspan="2">Latest Changelog Updates (<a href="changelog.php" style="color: darkorange;">Click here to see full changelog</a>)</td>
            </tr>
            <?php
            for ($i = 0; $i < count($changelogs) && $i < 5; $i++) {
                ?>
                <tr>
                    <td><?php echo getClock($changelogs[$i]['time'], true, true); ?></td>
                    <td><?php echo $changelogs[$i]['text']; ?></td>
                </tr>
                <?php
            }
            ?>
        </table></div></div>
        <?php
    } else echo "";
}
$cache = new Cache('engine/cache/news');
if ($cache->hasExpired()) {
    $news = fetchAllNews();
   
    $cache->setContent($news);
    $cache->save();
} else {
    $news = $cache->load();
}

// Design and present the list
if ($news) {
    function TransformToBBCode($string) {
        $tags = array(
            '[center]{$1}[/center]' => '<center>$1</center>',
            '[b]{$1}[/b]' => '<b>$1</b>',
            '[size={$1}]{$2}[/size]' => '<font size="$1">$2</font>',
            '[img]{$1}[/img]'    => '<a href="$1" target="_BLANK"><img src="$1" alt="image" style="width: 100%"></a>',
            '[link]{$1}[/link]'    => '<a href="$1">$1</a>',
            '[link={$1}]{$2}[/link]'   => '<a href="$1" target="_BLANK">$2</a>',
            '[color={$1}]{$2}[/color]' => '<font color="$1">$2</font>',
            '[*]{$1}[/*]' => '<li>$1</li>',
        );

        foreach ($tags as $tag => $value) {
            $code = preg_replace('/placeholder([0-9]+)/', '(.*?)', preg_quote(preg_replace('/\{\$([0-9]+)\}/', 'placeholder$1', $tag), '/'));
            $string = preg_replace('/'.$code.'/i', $value, $string);
        }

        return $string;
    }
    foreach ($news as $n) {
        ?>

        <div class="panel panel-default">
       
            <div class="panel-heading"><img style="margin-top: 0px; margin-left: 0px;" img="" id="Monster" src="layout\images\news2.gif"> <i class="status-online"></i> <b><font color="#dedede"> <?php echo TransformToBBCode($n['title']); ?></b></font> <i class="status-online"></i>  <?php echo getClock($n['date'], true); ?></div>
            <div class="panel-body">
           
                <?php echo TransformToBBCode(nl2br($n['text'])); ?>
            </div>
      </div>
     
     
      <br>
   
        <?php
    }
    echo '
    <script type="text/javascript">
        $(document).ready(function(){
            $(document).on("click", ".panel-heading", function(){
                $(this).siblings(".panel-body").toggle();
            });
        });
    </script>
    ';
}
?>
Work perfect!!! Thank you !
Only one question - possible to hide all (now i see all and must clik to hide) , or first last news visible and all others hide?
 
Sure, just do something like this:
PHP:
<?php
if ($config['UseChangelogTicker']) {
    //////////////////////
    // Changelog ticker //
    // Load from cache
    $changelogCache = new Cache('engine/cache/changelog');
    $changelogs = $changelogCache->load();

    if (isset($changelogs) && !empty($changelogs) && $changelogs !== false) {
        ?><hr>
        <div class="panel panel-default">
        <div class="panel-heading">
        <table id="changelogTable">
            <tr class="yellow">
                <td colspan="2">Latest Changelog Updates (<a href="changelog.php" style="color: darkorange;">Click here to see full changelog</a>)</td>
            </tr>
            <?php
            for ($i = 0; $i < count($changelogs) && $i < 5; $i++) {
                ?>
                <tr>
                    <td><?php echo getClock($changelogs[$i]['time'], true, true); ?></td>
                    <td><?php echo $changelogs[$i]['text']; ?></td>
                </tr>
                <?php
            }
            ?>
        </table></div></div>
        <?php
    } else echo "";
}
$cache = new Cache('engine/cache/news');
if ($cache->hasExpired()) {
    $news = fetchAllNews();
 
    $cache->setContent($news);
    $cache->save();
} else {
    $news = $cache->load();
}

// Design and present the list
if ($news) {
    function TransformToBBCode($string) {
        $tags = array(
            '[center]{$1}[/center]' => '<center>$1</center>',
            '[b]{$1}[/b]' => '<b>$1</b>',
            '[size={$1}]{$2}[/size]' => '<font size="$1">$2</font>',
            '[img]{$1}[/img]'    => '<a href="$1" target="_BLANK"><img src="$1" alt="image" style="width: 100%"></a>',
            '[link]{$1}[/link]'    => '<a href="$1">$1</a>',
            '[link={$1}]{$2}[/link]'   => '<a href="$1" target="_BLANK">$2</a>',
            '[color={$1}]{$2}[/color]' => '<font color="$1">$2</font>',
            '[*]{$1}[/*]' => '<li>$1</li>',
        );

        foreach ($tags as $tag => $value) {
            $code = preg_replace('/placeholder([0-9]+)/', '(.*?)', preg_quote(preg_replace('/\{\$([0-9]+)\}/', 'placeholder$1', $tag), '/'));
            $string = preg_replace('/'.$code.'/i', $value, $string);
        }

        return $string;
    }
 
    $i = 0;
    foreach ($news as $n) {
        ?>

        <div class="panel panel-default">
     
            <div class="panel-heading"><img style="margin-top: 0px; margin-left: 0px;" img="" id="Monster" src="layout\images\news2.gif"> <i class="status-online"></i> <b><font color="#dedede"> <?php echo TransformToBBCode($n['title']); ?></b></font> <i class="status-online"></i>  <?php echo getClock($n['date'], true); ?></div>
            <div class="panel-body" <?= ($i > 0) ? 'style="display:none"' : '' ?>>
         
                <?php echo TransformToBBCode(nl2br($n['text'])); ?>
            </div>
      </div>
   
   
      <br>
 
        <?php
        $i++;
    }
}
?>
 
Sure, just do something like this:
PHP:
<?php
if ($config['UseChangelogTicker']) {
    //////////////////////
    // Changelog ticker //
    // Load from cache
    $changelogCache = new Cache('engine/cache/changelog');
    $changelogs = $changelogCache->load();

    if (isset($changelogs) && !empty($changelogs) && $changelogs !== false) {
        ?><hr>
        <div class="panel panel-default">
        <div class="panel-heading">
        <table id="changelogTable">
            <tr class="yellow">
                <td colspan="2">Latest Changelog Updates (<a href="changelog.php" style="color: darkorange;">Click here to see full changelog</a>)</td>
            </tr>
            <?php
            for ($i = 0; $i < count($changelogs) && $i < 5; $i++) {
                ?>
                <tr>
                    <td><?php echo getClock($changelogs[$i]['time'], true, true); ?></td>
                    <td><?php echo $changelogs[$i]['text']; ?></td>
                </tr>
                <?php
            }
            ?>
        </table></div></div>
        <?php
    } else echo "";
}
$cache = new Cache('engine/cache/news');
if ($cache->hasExpired()) {
    $news = fetchAllNews();
 
    $cache->setContent($news);
    $cache->save();
} else {
    $news = $cache->load();
}

// Design and present the list
if ($news) {
    function TransformToBBCode($string) {
        $tags = array(
            '[center]{$1}[/center]' => '<center>$1</center>',
            '[b]{$1}[/b]' => '<b>$1</b>',
            '[size={$1}]{$2}[/size]' => '<font size="$1">$2</font>',
            '[img]{$1}[/img]'    => '<a href="$1" target="_BLANK"><img src="$1" alt="image" style="width: 100%"></a>',
            '[link]{$1}[/link]'    => '<a href="$1">$1</a>',
            '[link={$1}]{$2}[/link]'   => '<a href="$1" target="_BLANK">$2</a>',
            '[color={$1}]{$2}[/color]' => '<font color="$1">$2</font>',
            '[*]{$1}[/*]' => '<li>$1</li>',
        );

        foreach ($tags as $tag => $value) {
            $code = preg_replace('/placeholder([0-9]+)/', '(.*?)', preg_quote(preg_replace('/\{\$([0-9]+)\}/', 'placeholder$1', $tag), '/'));
            $string = preg_replace('/'.$code.'/i', $value, $string);
        }

        return $string;
    }
 
    $i = 0;
    foreach ($news as $n) {
        ?>

        <div class="panel panel-default">
    
            <div class="panel-heading"><img style="margin-top: 0px; margin-left: 0px;" img="" id="Monster" src="layout\images\news2.gif"> <i class="status-online"></i> <b><font color="#dedede"> <?php echo TransformToBBCode($n['title']); ?></b></font> <i class="status-online"></i>  <?php echo getClock($n['date'], true); ?></div>
            <div class="panel-body" <?= ($i > 0) ? 'style="display:none"' : '' ?>>
        
                <?php echo TransformToBBCode(nl2br($n['text'])); ?>
            </div>
      </div>
  
  
      <br>
 
        <?php
        $i++;
    }
}
?>

Perfect job!!! Thank you !!!
 
Back
Top