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 2

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 2

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 🙂

  • Like 1

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 4

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) 🙂

  • Like 1

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.

  • Like 1

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.

  • Like 1

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 🙂

  • Like 1
  • 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

 

  • Like 1
  • 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">

 

  • Like 1

Share this post


Link to post
Share on other sites

 

Hi @teppo,

thanks for the great module, we already use it with several customers.

I have a question concerning the savePageIndex-Hook: It works perfectly on saving a single page, but not, when I use the "Index pages now"-function in module settings page. How could I achieve this?

Best regards,

Thomas.

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 d'Hinnisdaël
      Happy new year, everybody 🥬
      I've been sitting on this Dashboard module I made for a client and finally came around to cleaning it up and releasing it to the wider public. This is how it looks.
      ProcessWire Dashboard

      If anyone is interested in trying this out, please go ahead! I'd love to get some feedback on it. If this proves useful and survives some real-world testing, I'll add this to the module directory.
      Download
      You can find the latest release on Github.
      Documentation
      Check out the documentation to get started. This is where you'll find information about included panel types and configuration options.
      Custom Panels
      My goal was to make it really simple to create custom panels. The easiest way to do that is to use the panel type template and have it render a file in your templates folder. This might be enough for 80% of all use cases. For anything more complex (FormBuilder submissions? Comments? Live chat?), you can add new panel types by creating modules that extend the DashboardPanel base class. Check out the documentation on custom panels or take a look at the HelloWorld panel to get started. I'm happy to merge any user-created modules into the main repo if they might be useful to more than a few people.
       Disclaimer
      This is a pre-release version. Please treat it as such — don't install it on production sites. Just making sure 🍇
      Roadmap
      These are the things I'm looking to implement myself at some point. The wishlist is a lot longer, but those are the 80/20 items that I probably won't regret spending time on.
      Improve documentation & add examples ⚙️ Panel types Google Analytics ⚙️ Add new page  🔥 Drafts 🔥 At a glance / Page counter 404s  Layout options Render multiple tabs per panel panel groups with heading and spacing between ✅ panel wrappers as grid item (e.g. stacked notices) ✅ Admin themes support AdminThemeReno and AdminThemeDefault ✅ Shortcuts panel add a table layout with icon, title & summary ✅ Chart panel add default styles for common chart types ✅ load chart data from JS file (currently passed as PHP array) Collection panel support image columns ✅ add buttons: view all & add new ✅
    • By Pip
      Hi everyone!
      I'm trying out the Login/Register module for my site. Noted that the module assigns the newly registered user to login-register role. 
      Once you modify the login-register role's permissions, particularly adding page-edit, the new member role will be set to guest. 
      Thing is I'd like to grant my new users the power to create their own pages. Any advice? 
      Thanks. 
    • By Gadgetto
      SnipWire - Snipcart integration for ProcessWire
      Snipcart is a powerful 3rd party, developer-first HTML/JavaScript shopping cart platform. SnipWire is the missing link between Snipcart and the content management framework ProcessWire.
      With SnipWire, you can quickly turn any ProcessWire site into a Snipcart online shop. The SnipWire plugin helps you to get your store up and running in no time. Detailed knowledge of the Snipcart system is not required.
      SnipWire is free and open source licensed under Mozilla Public License 2.0! A lot of work and effort has gone into development. It would be nice if you could donate an amount to support further development:

      Status update links (inside this thread) for SnipWire development
      2020-07-03 -- SnipWire 0.8.7 (beta) released! Fixes some small bugs and adds an indicator for TEST mode 2020-04-06 -- SnipWire 0.8.6 (beta) released! Adds support for Snipcart subscriptions and also fixes some problems 2020-03-21 -- SnipWire 0.8.5 (beta) released! Improves SnipWires webhooks interface and provides some other fixes and additions 2020-03-03 -- SnipWire 0.8.4 (beta) released! Improves compatibility for Windows based Systems. 2020-03-01 -- SnipWire 0.8.3 (beta) released! The installation and uninstallation process has been heavily revised. 2020-02-08 -- SnipWire 0.8.2 (beta) released! Added a feature to change the cart and catalogue currency by GET, POST or SESSION param 2020-02-03 -- SnipWire 0.8.1 (beta) released! All custom classes moved into their own namespaces. 2020-02-01 -- SnipWire is now available via ProcessWire's module directory! 2020-01-30 -- SnipWire 0.8.0 (beta) first public release! (module just submitted to the PW modules directory) 2020-01-28 -- added Custom Order Fields feature (first SnipWire release version is near!) 2020-01-21 -- Snipcart v3 - when will the new cart system be implemented? 2020-01-19 -- integrated taxes provider finished (+ very flexible shipping taxes handling) 2020-01-14 -- new date range picker, discount editor, order notifiactions, order statuses, and more ... 2019-11-15 -- orders filter, order details, download + resend invoices, refunds 2019-10-18 -- list filters, REST API improvements, new docs platform, and more ... 2019-08-08 -- dashboard interface, currency selector, managing Orders, Customers and Products, Added a WireTabs, refinded caching behavior 2019-06-15 -- taxes provider, shop templates update, multiCURL implementation, and more ... 2019-06-02 -- FieldtypeSnipWireTaxSelector 2019-05-25 -- SnipWire will be free and open source Plugin Key Features
      Fast and simple store setup Full integration of the Snipcart dashboard into the ProcessWire backend (no need to leave the ProcessWire admin area) Browse and manage orders, customers, discounts, abandoned carts, and more Multi currency support Custom order and cart fields Process refunds and send customer notifications from within the ProcessWire backend Process Abandoned Carts + sending messages to customers from within the ProcessWire backend Complete Snipcart webhooks integration (all events are hookable via ProcessWire hooks) Integrated taxes provider (which is more flexible then Snipcart own provider) Useful Links
      SnipWire in PW modules directory SnipWire Docs (please note that the documentation is a work in progress) SnipWire @GitHub (feature requests and suggestions for improvement are welcome - I also accept pull requests) Snipcart Website  

       
      ---- INITIAL POST FROM 2019-05-25 ----
       
    • By Sten
      Hello
      Till now I hacked something with the twig template but it works no more with new PW versions so I look forward to create a module. I am working on a site in multiple languages : French, English, Italian, German, Spanish, Portuguese, Hebrew, Russian. The new posts are entered in any language with a field for language. Till now, I got twig files to get the translations with constants defined for each part of the pages.
      So I'd like to create a module to include theses files added according to the url /fr/en/...
      Have you some observations to do before I begin about the direction to take ?
      Thank you
    • By ukyo
      Mystique Module for ProcessWire CMS/CMF
      Github repo : https://github.com/trk/Mystique
      Mystique module allow you to create dynamic fields and store dynamic fields data on database by using a config file.
      Requirements
      ProcessWire 3.0 or newer PHP 7.0 or newer FieldtypeMystique InputfieldMystique Installation
      Install the module from the modules directory:
      Via Composer:
      composer require trk/mystique Via git clone:
      cd your-processwire-project-folder/ cd site/modules/ git clone https://github.com/trk/Mystique.git Module in live reaction with your Mystique config file
      This mean if you remove a field from your config file, field will be removed from edit screen. As you see on youtube video.
      Using Mystique with your module or use different configs path, autoload need to be true for modules
      Default configs path is site/templates/configs/, and your config file name need to start with Mystique. and need to end with .php extension.
      Adding custom path not supporting anymore !
      // Add your custom path inside your module class`init` function, didn't tested outside public function init() { $path = __DIR__ . DIRECTORY_SEPARATOR . 'configs' . DIRECTORY_SEPARATOR; Mystique::add($path); } Mystique module will search site/modules/**/configs/Mystique.*.php and site/templates/Mystique.*.php paths for Mystique config files.
      All config files need to return a PHP ARRAY like examples.
      Usage almost same with ProcessWire Inputfield Api, only difference is set and showIf usage like on example.
      <?php namespace ProcessWire; /** * Resource : testing-mystique */ return [ 'title' => __('Testing Mystique'), 'fields' => [ 'text_field' => [ 'label' => __('You can use short named types'), 'description' => __('In file showIf working like example'), 'notes' => __('Also you can use $input->set() method'), 'type' => 'text', 'showIf' => [ 'another_text' => "=''" ], 'set' => [ 'showCount' => InputfieldText::showCountChars, 'maxlength' => 255 ], 'attr' => [ 'attr-foo' => 'bar', 'attr-bar' => 'foo' ] ], 'another_text' => [ 'label' => __('Another text field (default type is text)') ] ] ]; Example:
      site/templates/configs/Mystique.seo-fields.php <?php namespace ProcessWire; /** * Resource : seo-fields */ return [ 'title' => __('Seo fields'), 'fields' => [ 'window_title' => [ 'label' => __('Window title'), 'type' => Mystique::TEXT, // or InputfieldText 'useLanguages' => true, 'attr' => [ 'placeholder' => __('Enter a window title') ] ], 'navigation_title' => [ 'label' => __('Navigation title'), 'type' => Mystique::TEXT, // or InputfieldText 'useLanguages' => true, 'showIf' => [ 'window_title' => "!=''" ], 'attr' => [ 'placeholder' => __('Enter a navigation title') ] ], 'description' => [ 'label' => __('Description for search engines'), 'type' => Mystique::TEXTAREA, 'useLanguages' => true ], 'page_tpye' => [ 'label' => __('Type'), 'type' => Mystique::SELECT, 'options' => [ 'basic' => __('Basic page'), 'gallery' => __('Gallery'), 'blog' => __('Blog') ] ], 'show_on_nav' => [ 'label' => __('Display this page on navigation'), 'type' => Mystique::CHECKBOX ] ] ]; Searching data on Mystique field is limited. Because, Mystique saving data to database in json format. When you make search for Mystique field, operator not important. Operator will be changed with %= operator.
      Search example
      $navigationPages = pages()->find('my_mystique_field.show_on_nav=1'); $navigationPages = pages()->find('my_mystique_field.page_tpye=gallery');
×
×
  • Create New...