The pages module includes the following functions. You can use these in templates as well as layouts (though they are used primarily in the templates: projects_list.html and projects_view.html). All functions return values and never echo them, so that further operations can be made by themers/plugins/etc.
Displayers
projects( [string $options] )
returns HTML
This function is primarily used by the pageContent() function, but can also be used in layouts to display projects. It utilises the two projects templates, depending on supplied options and if a project is being viewed. Options can be “hard-coded” by supplying a comma separated list:
<?php echo projects( "show= big, tags= print, awards" ); ?>
projectContent( [int $id / string $slug] )
returns HTML
Use this function inside of the projects_view.html template to display the project's files. It sorts all the files into their respective groups and orders files, groups and textblocks according to how the user has ordered them in the back-end. Required JavaScript, CSS, etc for the various display types is automatically included by the system.
projectView()
returns HTML
Use this function in the layout_projects.php layout to display a project. Internally, it calls projects() with the following options line: show= big, id= [$project_id]. This in turn includes the projects_view.html template, which, in most cases, will contain a call to projectContent().
projectList()
returns HTML
This function is a useful theme function to automatically generate an HTML list of all projects. If the “Hide Section Titles” option is not on, then projects are divided for each section.
Sample list (note the 'active' class, which is automatically appended for CSS styling):
<ul id="projects"> <li> <ul id="print"> <li class="sectionTitle"> Print </li> <li class="project"> <a href="/projects/poster">Poster</a> </li> <li class="project active"> <a href="/projects/business-card">Business Card</a> </li> </ul> <ul id="web"> <li class="sectionTitle"> Web </li> <li class="project"> <a href="/projects/photographer-website">Photographer Website</a> </li> </ul> </li> </ul>
Project Details
projectTitle()
returns string
Returns the title of the current project. Can be used in both templates and layouts.
projectSlug()
returns string
Returns the slug of the current project. Can be used in both templates and layouts.
projectId()
returns int
Returns the database id of the current project. Can be used in both templates and layouts.
projectInfo( int $id / string $slug )
returns array
This function returns an array, directly from the database, containing all information about the requested project.
// Sample project array array( 'id' => 3, 'title' => 'Around the Corner', 'slug' => 'around-the-corner', 'date' => 543456000, 'section' => 2, 'pos' => 3, 'flow' => 'group1:one-by-one,textblock2,group2:pop', 'thumbnail' => 'aroundthecorner.project.jpg', 'publish' => 1 )
projectThumbnail()
returns HTML
Generates an IMG tag of the project thumbnail, to be used in templates, complete with width and height attributes. If there is no thumbnail attached to the project, the function returns:
<span>[project title]</span>
getProjectFiles()
returns array
Returns an array of all the files (including text blocks) from the selected project. Retrieved from the database. Can be used both templates and layouts.
// Sample project files array array( '27' => array( 'id' => 23, 'title' => 'Shadowplay', 'caption' => 'The dance of shadows as the sun crawls out from beneath the darkness.', 'file' => 'shadowplay.jpg', 'thumbnail' => 'shadowplay.thumb.jpg', 'width' => '600', 'height' => '800', 'project_id' => 3, 'pos' => 1 'type' => 'image', 'filegroup' => 2 ) )
Utility Functions
selectedProject()
returns string
Returns the slug of the selected (currently being viewed) project. This value is taken directly from the $_GET variable.
projectSelected()
returns true or false
Returns true if a project is being viewed.
linkToProject( [int $id / string $slug] )
returns string
This function creates a URL that can be used in an HTML link tag. It is automatically adjusted based on the clean URLs option. Especially useful in templates.
//Example usage in projects_list.html <a href="<?php echo linkToProject(); ?>"><?php echo projectTitle(); ?></a>
Tag Functions
linkToProjectTag( string $tag )
returns string
This function creates a URL that can be used to link to tags. Formatted based on the clean URLs option. Used internally in the projectTags() function.
projectHasTags()
returns true or false
Returns true if the project has been tagged. Useful if you want to display a tag list in a DIV, but only want that DIV to be displayed if there are tags to be shown.
projectTags()
returns HTML
Returns the project's tags as a linked, comma separated list:
<a href="/projects/tags/competition">competition</a>, <a href="/projects/tags/environment-friendly">environmentally friendly</a>, <a href="/projects/tags/awards">awards</a>
projectTagsArray()
returns array
Similar to projectTags(), but this function instead returns an array of the project's tags, so you can loop through it and do your own formatting/magic.
array( 0 => 'competition', 1 => 'environmentally-friendly', 2 => 'awards' )
currentProjectTags()
returns HTML
Same as projectTags(), except it returns the selected tags. If the user has clicked a tag link and is now viewing the URL www.domain.com/projects/tags/awards, this function will return HTML containing a link to the 'awards' tag. This is useful if you wish to display a list of “currently viewing tags”. Note that tags can be stacked, like so: www.domain.com/projects/tags/awards,competition,environmentally-friendly
currentProjectTagsArray()
returns array
Same as currentProjectTags(), but instead returns an array for your own magic-doing, in the same format as projectTagsArray().
allProjectTags()
returns HTML
Same as projectTags(), but returns all tags in the database, for a tag cloud-esque list.
allProjectTagsArray()
Same as projectTagsArray(), but returns all tags in the database. Useful for creating your own tag cloud functions.