Search the Community
Showing results for tags 'tag'.
-
A simple recursive function that walks over all image fields and those inside repeaters(including FieldtypeFieldsetPage) to find images tagged with a certain tag(s). It can easily be extended to file fields by changing instanceof FieldtypeImage to FieldtypeFile, or be restricted to file fields by adding a !$type instanceof FieldtypeFile, too. Adapted from ProcessPageEditLink::getFilesPage() method. /** * Find all images tagged with a certain tag in a page including repeater items. * * @param $page Page to search tagged images * @param $tag string|array Image tag(s). Can be 'foo' for single, 'foo|bar' for multiple OR tags, 'foo,bar' or ['foo', 'bar'] for multiple AND tags * @return array Tagged images in [basename => Pageimage] associated array form or empty an array */ function findTaggedImages(Page $page, $tag) { $tagged = []; foreach ($page->template->fieldgroup as $f) { $type = $f->type; if ($type instanceof FieldtypeImage) { /** @var Pageimages $images */ $images = $page->{$f->name}; if (!$images) continue; $tagged = array_merge($tagged, $images->findTag($tag)->getArray()); } else if ($type instanceof FieldtypeRepeater) { $items = $page->{$f->name}; if (!$items) continue; if ($items instanceof PageArray) { foreach ($page->$f as $item) $tagged = array_merge($tagged, findTaggedImages($item, $tag)); } // FieldtypeFieldsetPage returns a single page instead of a PageArray elseif ($items instanceof Page) { $tagged = array_merge($tagged, findTaggedImages($items, $tag)); } } } return $tagged; } And can be used as $featuredImages = findTaggedImages($page, 'featured'); // get first featured image $featured = reset($featuredImages); // or array_shift($featuredImages)
-
i am using CKEditor and want the design to be like the image below is there a way to get rid auf the <p>-tag around ther inserted image and also keep the <p>-tag around the text? <p>text</p> <p><img></p> <p>text</p> to <p></p> <img> <p></p>
-
Hi there, I am new on using PW. So this is my first Post. In order of that, i want to say Hello to everybody. I used PW, to create a Blog with Tagging Function. I used the Page Field Type to create a new Page from a new Tag, defined in a Blog Article. My Problem is, when I create a New Tag for example "Title A" the Tag and a Page is correctly been created. But the URL of the new Tag Page is a fallback solution like 2014-12-16.... How it is possible to define a custom URL from the Title, as PW does, when I "manually" create a new Page. The easiest Way is the Favorite. I thought I can hook up the Page-Save-Event to Auto-Create a URL, but that would be not that easy. Also I have to fill 2 Fields because its a multilanguage Site. Can anybody help? Greetings from Germany
-
If I am implementing a 'free tagging field', which is explained by @ryan here > https://processwire.com/talk/topic/71-categorizingtagging-content/ is there any way to do this for more than one word (for example if a tag I entered is 'green energy') So, I have a tag.php template which uses something like: <?php if ( $tag = $sanitizer->selectorValue($input->urlSegment1) ) : ?> <?php $matches = $pages->find("tags*=$tag"); ?> <?php foreach ($matches as $match) : ?> <?php endforeach; ?> <?php endif; ?> This allows me, using url segments, to do: /tags/green and the results with a tag 'green', would come up. But how would I do it for something like 'green energy', so /tags/green+energy or /tags/green-energy... Currently my free tagging field is just a text field, but I could make this into a repeater, for example, if it helps this situation. Thanks in advance
-
Hey hello, Basic question: If I have tagged posts, and I would like to list all tags (in this case it's a bunch of associated pages; 'page'-type) that have been used at least once, I'd have to loop throught all posts, right? There is no shortcut? thanks! J