Jump to content
teppo

SearchEngine

Recommended Posts

@teppo Perhaps my comment from February got lost in the mix.

This search function is such a great addition to the ProcessWire ecosystem.

I am wondering if you would consider adding FieldsetPage fields to the list of searchable fields?

I use FieldsetPage fields often to create components. From there it is a mater of adding that one field to a template or a repeater to add the component.

Thank you for your time.

Share this post


Link to post
Share on other sites
1 hour ago, GhostRider said:

I am wondering if you would consider adding FieldsetPage fields to the list of searchable fields?

I use FieldsetPage fields often to create components. From there it is a mater of adding that one field to a template or a repeater to add the component.

Sorry for taking so long to reply — this is now the top item on my todo list. I'll try to get it included sometime soon!

  • Like 1

Share this post


Link to post
Share on other sites

@GhostRider, FieldsetPage support is now included with module version 0.20.0. I didn't have much to test with, but it did seem to work as expected on my limited use case — let me know if you run into any issues and I'll be happy to take a closer look 🙂

  • Like 1

Share this post


Link to post
Share on other sites

Hi @teppo. Thanks for addressing this. I'll give it a test drive later today or tomorrow on a current project.

  • Like 1

Share this post


Link to post
Share on other sites

@teppo Thanks for your help! Sorry for the delay (and sorry I have to get back to this). Yes, you're right, I use Hanna Code on my site. My code works fine though except when called by your indexer. I noticed another thing: When trying to save the page which calls my HC, PW gives the same error as above.

This is the content of my HC causing the trouble:

if($page->images_gallery->count()) { // images_gallery is a repeater field
	$gallery = "<div class='gallery'>";
	foreach($page->images_gallery as $img) {
	    if($img->image_caption) {
		    $titleAttr = "title='" . strip_tags($img->image_caption) . "'";
		    $imgCaption = "<div class='lightbox-caption'>$img->image_caption</div>";
	    } else {
	        $titleAttr = "";
	        $imgCaption = "";
	    }
		$gallery .= "
			<a href='{$img->image->url}' $titleAttr>
				<img src='" . $img->image->size(250, 250)->url . "' alt='" . $img->image->description . "'>
				$imgCaption
			</a>
		";
	}
	$gallery .= "</div>";
	echo $gallery;
}

This is tailored to output formatting being on, as is usually the case when HC is called. How does your indexer handle OF when it pulls content from fields? I'm still confused by the fact that triggering your indexer via API does NOT lead to any error. The error seems to appear only when the backend is "involved". Any ideas? Thanks a lot!

Share this post


Link to post
Share on other sites

Hi @teppo, thanks very much for creating this module.

We are looking to include a site search on a client's website. The website uses sub pages as on-page blocks that are rendered out as part of the parent page (allows for some nice flexible layouts). Do you know if this module would be suitable for also searching through these blocks and displaying the relative parent link in the search results?

Share this post


Link to post
Share on other sites

Hy, Thanks for the module.

Just wanted to try it today. An upon uploading the module on my processwire installation. I got this parse error message (syntax error, unexpected '?' line 478).
I am running it on the latest stable processwire version and php 7.x.

Thanks in advance

 

Share this post


Link to post
Share on other sites
On 4/16/2020 at 12:04 PM, CalleRosa40 said:

@teppo Thanks for your help! Sorry for the delay (and sorry I have to get back to this). Yes, you're right, I use Hanna Code on my site. My code works fine though except when called by your indexer. I noticed another thing: When trying to save the page which calls my HC, PW gives the same error as above.

...

This is tailored to output formatting being on, as is usually the case when HC is called. How does your indexer handle OF when it pulls content from fields? I'm still confused by the fact that triggering your indexer via API does NOT lead to any error. The error seems to appear only when the backend is "involved". Any ideas? Thanks a lot!

Sorry for the delay from my part as well... 😅

Indexer grabs the value using $page->getFormatted($field_name). This means that output formatting is temporarily enabled for the page, value is read, and then output formatting is disabled (assuming it was disabled in the first place).

I'm not able to make this work via the API either — getting the same error there, so I'm also somewhat confused about this. Could mean that there's some difference in the way we're testing this. Anyway, both $page->save() and direct call to SearchEngine::indexPage($page) lead to the exact same error in my tests using your Hanne Code snippet 🙂

In this case the problem seems to be that your Hanna Code snippet is accessing Repeater Pages that were loaded with output formatting disabled (FieldtypeRepeater::___wakeupValue()). I've been trying to work around this for a while now, but to be honest I have no idea how to do that without causing potential issues and/or slowdowns elsewhere. I do have a couple of ideas I'd like to try, but it may take a while to figure this out, and even then the conclusion could be that this is simply too much of a hassle to automatically handle in SearchEngine.

The TL;DR here is that at least for the time being a slight modification is required for the Hanna Code snippet:

	foreach($page->images_gallery as $img) {
		$img->of(true);

(Or, alternatively, you could get $img->image with $img->getFormatted('image').)

I'll keep trying, but I can't give you any promises regarding a possible future Hanna Code compatibility enhancement yet 🙂

Share this post


Link to post
Share on other sites
On 5/4/2020 at 11:52 AM, 999design said:

We are looking to include a site search on a client's website. The website uses sub pages as on-page blocks that are rendered out as part of the parent page (allows for some nice flexible layouts). Do you know if this module would be suitable for also searching through these blocks and displaying the relative parent link in the search results?

Hey @999design!

SearchEngine can handle pages that are stored in PageTable or Repeater fields automatically, but if you're literally using subpages and there's no backend / field level connection between the parent and the children, then this would (at least for now) require a custom hook. In other words you can use SearchEngine, but you'll have to add a bit of extra code to populate the index.

Something like this should do it:

$wire->addHookAfter('SearchEngine::savedPageIndex', function(HookEvent $event) {
	$page = $event->arguments[0];
	if ($page->template == 'ContainerPage' && $page->children->count()) {
		$searchEngine = $event->modules->get('SearchEngine');
		foreach ($page->children as $child) {
			$child_index = $searchEngine->indexPage($child, false, [
				'return' => 'index',
			]);
			$page->search_index .= "\n" . $child_index[0];
		}
		$page->save('search_index', [
			'quiet' => true,
			'noHooks' => true,
		]);
	}
});

Note that you need to use SearchEngine 0.21.0 for this to work; I just released a new version that made Indexer::indexPage() a bit more flexible. Also note that if you're building a multi-lingual site, indexPage() will return an array where the index is language ID, and you'll need to use setLanguageValue() to store it for each language one by one 🙂

  • Like 3

Share this post


Link to post
Share on other sites
9 hours ago, antpre said:

Hy, Thanks for the module.

Just wanted to try it today. An upon uploading the module on my processwire installation. I got this parse error message (syntax error, unexpected '?' line 478).
I am running it on the latest stable processwire version and php 7.x.

Hey @antpre!

Could you check what's on that line and paste it here, and also double check your PHP version? If I'm looking at the correct line of code, 478 should be this one:

    public function createIndexField(string $index_field_name, string $redirect_url = null): ?Field {

... and if that's the case, the only matching issue I can think of would be the use of nullable return type ("?Field"). Support for nullable return types was added in PHP 7.1, so this would suggest that either you're running an earlier version of PHP, or there's something else wrong with the setup (or perhaps I've got the wrong line) 🙂

Share this post


Link to post
Share on other sites
13 hours ago, teppo said:

Hey @999design!

SearchEngine can handle pages that are stored in PageTable or Repeater fields automatically, but if you're literally using subpages and there's no backend / field level connection between the parent and the children, then this would (at least for now) require a custom hook. In other words you can use SearchEngine, but you'll have to add a bit of extra code to populate the index.

Something like this should do it:


$wire->addHookAfter('SearchEngine::savedPageIndex', function(HookEvent $event) {
	$page = $event->arguments[0];
	if ($page->template == 'ContainerPage' && $page->children->count()) {
		$searchEngine = $event->modules->get('SearchEngine');
		foreach ($page->children as $child) {
			$child_index = $searchEngine->indexPage($child, false, [
				'return' => 'index',
			]);
			$page->search_index .= "\n" . $child_index[0];
		}
		$page->save('search_index', [
			'quiet' => true,
			'noHooks' => true,
		]);
	}
});

Note that you need to use SearchEngine 0.21.0 for this to work; I just released a new version that made Indexer::indexPage() a bit more flexible. Also note that if you're building a multi-lingual site, indexPage() will return an array where the index is language ID, and you'll need to use setLanguageValue() to store it for each language one by one 🙂

That's amazing, thank you very much for the detailed reply @teppo . We now have a few good options to suggest to our client.

Much appreciated 🙂

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for your answer... and indeed i am runing php 7.0.33.

Regards

Share this post


Link to post
Share on other sites

It’s been a while since I developed a new project with PW, but I have an upcoming client/project that could certainly use SearchEngine. I have a question about search results:

Is SearchEngine able to return results into groups? For instance, the client is a home builder/seller. If a user performs a search, it would be nice to return the results as sets. In their case, single-floor homes; two-story homes; etc. That’s just an example. The bottom line is that their homes are divided into categories, so it would be nice if users could see results grouped as such.

Is this possible?

  • Like 1

Share this post


Link to post
Share on other sites
17 hours ago, fuzenco said:

Is SearchEngine able to return results into groups? For instance, the client is a home builder/seller. If a user performs a search, it would be nice to return the results as sets. In their case, single-floor homes; two-story homes; etc. That’s just an example. The bottom line is that their homes are divided into categories, so it would be nice if users could see results grouped as such.

Is this possible?

At the moment SearchEngine doesn't have built-in support for this.

That being said: you could create a custom search page and use SearchEngine to index and (optionally) find items, which you then output manually. Or you could hook into Renderer::renderResults() and customize the output there. So yeah, there are ways to handle this, but it will require a bit of extra work 🙂

Out of interest: is each group going to contain items of a single template, i.e. in your example would "single-floor home" and "two-story home" be templates, or would this be some sort of option on a shared template (integer, options field, or something along those lines)? Grouping results by template might actually be a good idea as a built-in feature, just wondering if that'd work in your case.

Share this post


Link to post
Share on other sites
On 7/16/2019 at 9:41 AM, teppo said:

Anyway, currently the ("full", i.e. a form and a results list) rendered state looks like this:

 

#1 "Full" result
How can I get this "full" result? The "standard" rendering outputs just the title and the URL.

#2 Languages
I assume that it needs "manual" rendering to output a language specific output … instead of english ("Search results", "x results for:", and so on) …

#3 Select (product) field
Taking consideration of #1 and #2 … I have a repeater matrix in the basic-page(es). I use manual indexing in the SearchEngine Module. RepeaterMatrix > Text fields are working well with this setup. I set the "search_index" field to "visible in editor" and this is what it stores (for example in french):

Vente au détail Solutions pour votre application de vente au détail Si vous êtes propriétaire d'un appartement, responsable d'un datacentre ou directeur d'hôtel, nous avons des exemples et des solutions pour chaque besoin d'application. Array Exemples &amp; Solutions : Array Array Array Array 
{}

(…there's a lot of "Array" here… hmm…)

One of the repeater matrix items is just an option field (to select a product category [green products, yellow products, brown products…]). This is just an information what to render in frontend, but the product texts are stored in different pages. So there is no text/product-infos to store in the "search_index" field.

How can I manage to insert the selected products into the "search_index" field?

My first thought was to add a new field to the template… let's call it "search_dump". On every "page save" I populate this text area according to the RepeaterMatrix -> product_selection field (I guess this can be done by a hook). Then I have to recreate the search index manually in the backend GIU or by API:

$modules->get('SearchEngine')->indexPage($page);

Share this post


Link to post
Share on other sites
On 5/23/2020 at 11:05 AM, teppo said:

Out of interest: is each group going to contain items of a single template, i.e. in your example would "single-floor home" and "two-story home" be templates, or would this be some sort of option on a shared template (integer, options field, or something along those lines)? Grouping results by template might actually be a good idea as a built-in feature, just wondering if that'd work in your case.

Generally, this would be a shared template as the homes all contain the same content blocks (title, description, number of bedrooms, number of bathrooms, picture gallery, etc.). The only difference really is the classification of homes. Years ago, I used to work with the CMS Expression Engine which would allow for this type of grouping. I can’t remember how it did it, but it was was useful.

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, fuzenco said:

Generally, this would be a shared template as the homes all contain the same content blocks (title, description, number of bedrooms, number of bathrooms, picture gallery, etc.). The only difference really is the classification of homes. Years ago, I used to work with the CMS Expression Engine which would allow for this type of grouping. I can’t remember how it did it, but it was was useful.

Thanks for the clarification 🙂

Grouping can be done by pretty much any imaginable way with ProcessWire data types as well, but I was wondering if this would be solvable with something that's "generic enough" to be added to the module as a feature. Technically I could add settings for grouping with custom fields etc. as well, but that sounds like it would be a lot more complex — as a module setting, meaning that it would have to work with a lot of different configurations — than just by template.

Share this post


Link to post
Share on other sites
On 5/25/2020 at 6:36 PM, 2hoch11 said:

#1 "Full" result
How can I get this "full" result? The "standard" rendering outputs just the title and the URL.

The view in the screenshot is what you should get by calling  <?= $modules->get('SearchEngine')->render() ?>.

If you mean that you get the search form and a list of results but the results don't have a summary field, then it's possible that you need to define the summary field — this is assuming that your pages don't actually have a filled-in summary field on them:

$config->SearchEngine = [
    'render_args' => [
        // Summary of each result (in the search results list) is the value of this field.
        'result_summary_field' => 'summary',
    ],
];
On 5/25/2020 at 6:36 PM, 2hoch11 said:

#2 Languages
I assume that it needs "manual" rendering to output a language specific output … instead of english ("Search results", "x results for:", and so on) …

These are all translatable strings — so no, manual rendering is not needed, you just need to translate the module files to your language 🙂

On 5/25/2020 at 6:36 PM, 2hoch11 said:

#3 Select (product) field
Taking consideration of #1 and #2 … I have a repeater matrix in the basic-page(es). I use manual indexing in the SearchEngine Module. RepeaterMatrix > Text fields are working well with this setup. I set the "search_index" field to "visible in editor" and this is what it stores (for example in french):


Vente au détail Solutions pour votre application de vente au détail Si vous êtes propriétaire d'un appartement, responsable d'un datacentre ou directeur d'hôtel, nous avons des exemples et des solutions pour chaque besoin d'application. Array Exemples &amp; Solutions : Array Array Array Array 
{}

(…there's a lot of "Array" here… hmm…)

The array part is interesting. perhaps options field (if I understood the next part correctly and this is what you're using here) isn't getting indexed quite right; I'll take a closer look at that soon.

On 5/25/2020 at 6:36 PM, 2hoch11 said:

One of the repeater matrix items is just an option field (to select a product category [green products, yellow products, brown products…]). This is just an information what to render in frontend, but the product texts are stored in different pages. So there is no text/product-infos to store in the "search_index" field.

How can I manage to insert the selected products into the "search_index" field?

My first thought was to add a new field to the template… let's call it "search_dump". On every "page save" I populate this text area according to the RepeaterMatrix -> product_selection field (I guess this can be done by a hook). Then I have to recreate the search index manually in the backend GIU or by API:


$modules->get('SearchEngine')->indexPage($page);

The code I posted a few replies ago on this thread was actually almost directly applicable to your case as well. Here's a rough idea — you still need to fill in the blanks, most importantly the way you're fetching those products:

$wire->addHookAfter('SearchEngine::savedPageIndex', function(HookEvent $event) {
	$page = $event->arguments[0];
	if ($page->template == 'TemplateWithProducts') {
		$searchEngine = $event->modules->get('SearchEngine');

        // I don't know exactly how you're fetching those products; include your logic here :)
        $products = $pages->find('template=product, some_rule=' . $page->some_field);

        foreach ($products as $product) {
            $product_index = $searchEngine->indexPage($product, false, [
				'return' => 'index',
			]);
			$page->search_index .= "\n" . $product_index[0];
        }
		$page->save('search_index', [
			'quiet' => true,
			'noHooks' => true,
		]);
	}
});

Note that if this is a multi-lingual site, that will require some additional tweaks (indexPage() will return an index value per language, and you need to use setLanguageValue() to store it).

Let me know if any of this doesn't seem quite right, and I'll be happy to take a closer look 🙂

  • Thanks 1

Share this post


Link to post
Share on other sites

Hi,

I installed Search Engine and it looks like it's working. Thank you! I just noticed I now have this error every time I save a blog entry.

"Method Pageimages::width does not exist or is not callable in this context"

Based on a previous reply, it appears it's a hanna code issue, but this code does output an image on the front end... Is there something wrong with it?

 

$page=$pages->get($id); //gets the page
    
$image = $page->image->width(1240, ["suffix" => "srcset"]); //create image that is 1200px wide

Thank you for any clues on how to fix it.

Regards,

 

Share this post


Link to post
Share on other sites

Hey @montero4,

First of all, just wanted to say that I really need to figure out some way to handle these conflicts with Hanna Code — it's becoming a common issue. I'll see what I can do about that soon 🙂

Technically there's nothing wrong in your code. It will work just fine on the front-end, where it's really intended to run. The problem is that in order to get useful index out of field content, SearchEngine actually gets it via $page->getFormatted(), which means that TextFormatters (such as Hanna Code) will also run in the admin side.

In this case you're using $pages->get() to get another Page, and since the default in the admin is that output formatting is off, this means that this new Page will have output formatting disabled — and that's why $page->image actually returns an instance of Pageimages (instead of a single Pageimage).

... anyway, just wanted to explain what's going on in here 🙂

Right now the easy fix would be checking for the type in the Hanna Code snippet. (Again, I'd like to automatically handle this in SearchEngine, but I can't say for sure when I'll get to that.)

$page=$pages->get($id); //gets the page
    
$image = $page->image instanceof Pageimages ? $page->image->eq(0) : $page->image;
$image = $image->width(1240, ["suffix" => "srcset"]); //create image that is 1200px wide

Alternatively you could make sure that output formatting state is on — it's mostly a matter of taste, really:

$page=$pages->get($id); //gets the page

$of = $page->of() // store initial output formatting state for later use
$page->of(true); // make sure that output formatting is on
    
$image = $page->image->width(1240, ["suffix" => "srcset"]); //create image that is 1200px wide

$page->of($of); // restore initial output formatting state

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Using the module on a multi-language site. When saving a page, I get the following error: "Call to a member function setLanguageValue() on string", File: .../modules/SearchEngine/lib/Indexer.php:99

 98:                        if ($index_field_exists) {
 99:                            $page->get($index_field)->setLanguageValue($language, $index[$language->id]);
101:                        }

I suppose we need a $page->of(false) here before calling setLanguageValue() ?

Share this post


Link to post
Share on other sites
On 5/26/2020 at 10:41 AM, teppo said:

Thanks for the clarification 🙂

Grouping can be done by pretty much any imaginable way with ProcessWire data types as well, but I was wondering if this would be solvable with something that's "generic enough" to be added to the module as a feature. Technically I could add settings for grouping with custom fields etc. as well, but that sounds like it would be a lot more complex — as a module setting, meaning that it would have to work with a lot of different configurations — than just by template.

Yes, I can imagine it would be complex. I think ExpressionEngine did it by means of an inline group-by. For instance:

<li class="whatever" groupby="datacolumn">

And then there was a sort-by also:

<li class="whatever" groupby="datacolumn" sortby="whatever">

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By MoritzLost
      This module allows you to integrate hCaptcha bot / spam protection into ProcessWire forms. hCaptcha is a great alternative to Google ReCaptcha, especially if you are in the EU and need to comply with privacy regulations.

      The development of this module is sponsored by schwarzdesign.
      The module is built as an Inputfield, allowing you to integrate it into any ProcessWire form you want. It's primarily intended for frontend forms and can be added to Form Builder forms for automatic spam protection. There's a step-by-step guide for adding the hCaptcha widget to Form Builder forms in the README, as well as instructions for API usage.
      Features
      Inputfield that displays an hCaptcha widget in ProcessWire forms. The inputfield verifies the hCaptcha response upon submission, and adds a field error if it is invalid. All hCaptcha configuration options for the widget (theme, display size etc) can be changed through the inputfield configuration, as well as programmatically. hCaptcha script options can be changed through a hook. Error messages can be translated through ProcessWire's site translations. hCaptcha secret keys and site-keys can be set for each individual inputfield or globally in your config.php. Error codes and failures are logged to help you find configuration errors. Please check the README for setup instructions.
      Links
      Github Repository and documentation InputfieldHCaptcha in the module directory (pending approval) Screenshots (configuration)

      Screenshots (hCaptcha widget)

       
       

       
    • By joshua
      This module is (yet another) way for implementing a cookie management solution.
      Of course there are several other possibilities:
      - https://processwire.com/talk/topic/22920-klaro-cookie-consent-manager/
      - https://github.com/webmanufaktur/CookieManagementBanner
      - https://github.com/johannesdachsel/cookiemonster
      - https://www.oiljs.org/
      - ... and so on ...
      In this module you can configure which kind of cookie categories you want to manage:

      You can also enable the support for respecting the Do-Not-Track (DNT) header to don't annoy users, who already decided for all their browsing experience.
      Currently there are four possible cookie groups:
      - Necessary (always enabled)
      - Statistics
      - Marketing
      - External Media
      All groups can be renamed, so feel free to use other cookie group names. I just haven't found a way to implement a "repeater like" field as configurable module field ...
      When you want to load specific scripts ( like Google Analytics, Google Maps, ...) only after the user's content to this specific category of cookies, just use the following script syntax:
      <script type="text/plain" data-type="text/javascript" data-category="statistics" data-src="/path/to/your/statistic/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="marketing" data-src="/path/to/your/mareketing/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="external_media" data-src="/path/to/your/external-media/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="marketing">console.log("Inline scripts are also working!");</script> The type has to be "optin" to get recognized by PrivacyWire, the data-attributes are giving hints, how the script shall be loaded, if the data-category is within the cookie consents of the user. These scripts are loaded asynchronously after the user made the decision.
      If you want to give the users the possibility to change their consent, you can use the following Textformatter:
      [[privacywire-choose-cookies]] It's planned to add also other Textformatters to opt-out of specific cookie groups or delete the whole consent cookie.
      You can also add a custom link to output the banner again with a link / button with following class:
      <a href="#" class="privacywire-show-options">Show Cookie Options</a> <button class="privacywire-show-options">Show Cookie Options</button> This module is still in development, but we already use it on several production websites.
      You find it here: PrivacyWire Git Repo
      Download as .zip
      I would love to hear your feedback 🙂
      CHANGELOG
      0.1.1 Debugging: fixed error during uninstall 0.1.0 Added new detection of async scripts for W3C Validation 0.0.6 CSS-Debugging for hiding unused buttons, added ProCache support for the JavaScript tag 0.0.5 Multi-language support included completely (also in TextFormatter). Added possibility to async load other assets (e.g. <img type="optin" data-category="marketing" data-src="https://via.placeholder.com/300x300">) 0.0.4 Added possibility to add an imprint link to the banner 0.0.3 Multi-language support for module config (still in development) 0.0.2 First release 0.0.1 Early development
    • By bernhard
      --- Please use RockFinder3 ---
    • By MoritzLost
      Cacheable Placeholders
      This module allows you to have pieces of dynamic content inside cached output. This aims to solve the common problem of having a mostly cacheable site, but with pieces of dynamic output here and there.  Consider this simple example, where you want to output a custom greeting to the current user:
      <h1>Good morning, <?= ucfirst($user->name) ?></h1> This snippet means you can't use the template cache (at least for logged-in users), because each user has a different name. Even if 99% of your output is static, you can only cache the pieces that you know won't include this personal greeting. A more common example would be CSRF tokens for HTML forms - those need to be unique by definition, so you can't cache the form wholesale.
      This module solves this problem by introducing cacheable placeholders - small placeholder tokens that get replaced during every request. The replacement is done inside a Page::render hook so it runs during every request, even if the response is served from the template cache. So you can use something like this:
      <h1>Good morning, {{{greeting}}}</h1> Replacement tokens are defined with a callback function that produces the appropriate output and added to the module through a simple hook:
      // site/ready.php wire()->addHookAfter('CachePlaceholders::getTokens', function (HookEvent $e) { $tokens = $e->return; $tokens['greeting'] = [ 'callback' => function (array $tokenData) { return ucfirst(wire('user')->name); } ]; $e->return = $tokens; }); Tokens can also include parameters that are parsed and passed to the callback function. There are more fully annotated examples and step-by-step instructions in the README on Github!
      Features
      A simple and fast token parser that calls the appropriate callback and runs automatically. Tokens may include multiple named or positional parameters, as well as multi-value parameters. A manual mode that allows you to replace tokens in custom pieces of cached content (useful if you're using the $cache API). Some built-in tokens for common use-cases: CSRF-Tokens, replacing values from superglobals and producing random hexadecimal strings. The token format is completely customizable, all delimiters can be changed to avoid collisions with existing tag parsers or template languages. Links
      Github Repository & documentation Module directory (pending approval) If you are interested in learning more, the README is very extensive, with more usage examples, code samples and usage instructions!
    • By Craig
      I've been using Fathom Analytics for a while now and on a growing number of sites, so thought it was about time there was a PW module for it.
      WayFathomAnalytics
      WayFathomAnalytics is a group of modules which will allow you to view your Fathom Analytics dashboard in the PW admin panel and (optionally) automatically add and configure the tracking code on front-end pages.
      Links
      GitHub Readme & documentation Download Zip Modules directory Module settings screenshot What is Fathom Analytics?
      Fathom Analytics is a simple, privacy-focused website analytics tool for bloggers and businesses.

      Stop scrolling through pages of reports and collecting gobs of personal data about your visitors, both of which you probably don't need. Fathom is a simple and private website analytics platform that lets you focus on what's important: your business.
      Privacy focused Fast-loading dashboards, all data is on a single screen Easy to get what you need, no training required Unlimited email reports Private or public dashboard sharing Cookie notices not required (it doesn't use cookies or collect personal data) Displays: top content, top referrers, top goals and more
×
×
  • Create New...