Skip to content

Sebi2020/FieldtypeTags

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

Provides a Tag field for ProcessWire CMS pages.

Installation

Just clone or put this into a folder and install the module from the module admin page of ProcessWire.

Getting Tags in Templates

Just access this field like any other field of ProcessWire. This field returns an normal PHP Array.

Examples

Retrieve tags related to the current page

// Fetch the tag field. Here it's called "Tags'.
$tags = $page->Tags;
foreach($tags as $tag) {
	echo "Tag: " . $tag;
}

Retrieve alphabetically sorted tags, frequency and related pages

// Retrieve the module
$tags = $this('modules')->get("FieldtypeTags");

// Fetch all tags and their frequency.
foreach($tags->getAllTags("Tags") as $field => $count) {
	echo "<h2>Tag \"{$field}\" (used {$count} times)</h2>";
	echo "<ul>";

	// Fetch all pages for a given tag
	foreach($tags->getPagesByTag($field) as $page) {
		echo "<li><a href=\"{$page->url}\">{$page->title}</a></li>";
	}
	echo "</ul>";
}

Inputfields

As far as I know, there are currently no single input input fields that output arrays. Maybe you should consider to use the InputfieldTagify I created for this fieldtype.