Archives array

From Photostand Wiki

Jump to: navigation, search
archives_array(numposts)

The archives_array function is used within a loop to display the thumbnails in the archives.php page. The loop it self must always be foreach and the value variable in the loop MUST always be $article.

Here's the usage syntax of archives_array :

foreach(archives_array(numposts) as $article)
{
    ...
}

The variable $article contains the thumbnail id used by other archives functions. The loop will repeat the code placed between { and } for each article.

Parameters

  • Numposts : Integer value

Maximum number of tumbnails that must be displayed in a page in the archives.

Examples

In the archives.php page

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>

	<title>Archives</title>

    </head>
    <body>

        <ul>
	    <?php
    	    foreach(archives_array(50) as $article)
    	    { 
    	    ?>
     	    <li>A thumbnail here.</li>
	    <?php
    	    }
	    ?>
	</ul>

    </body>
</html>

Here, the loop will display <li>A thumbnail here.</li> for each article (maximum 50 times). This is not really usefull because it will always display the same thing for each article, so let's see how to display thumbnails in the archives.

Displaying thumbnails

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>

	<title>Archives</title>

    </head>
    <body>

        <ul>
	    <?php
    	    foreach(archives_array(50) as $article)
    	    { 
    	    ?>
     	    <li><img src="<?php echo archives_thumbnail(); ?>" class="thumbnail" /></li>
	    <?php
    	    }
	    ?>
	</ul>

    </body>
</html>

In this example, for each article to be displayed, an image will be shown. The function Archives_thumbnail returns the current thumbnail path. As for the previous example, a maximum of 50 thumbnails will be displayed.

Personal tools