suntrop
-
Posts
316 -
Joined
Posts posted by suntrop
-
-
That's right, a regular array will survive the redirect.
-
Hi all. Perhaps this is just my fault, but I can't get behind it :-(
When I store an array in a $session and want to read its contents – after a $session->redirect() – it is NULL by var_dump()
If I use the exact same code and just store a string or a Page ID the output is correct.
// file-1, product page $last_add_to_cart['product'] = $selected_product; $last_add_to_cart['quantity'] = $selected_product_quantity; $session->last_add_to_cart = $last_add_to_cart; $session->redirect('/warenkorb/'); // file-2, cart var_dump($session->last_add_to_cart); // is NULL
Strangely this works
// file-1, product page $last_add_to_cart['product'] = $selected_product->id; #$last_add_to_cart['quantity'] = $selected_product_quantity; $session->last_add_to_cart = $last_add_to_cart; $session->redirect('/warenkorb/'); // file-2, cart var_dump($session->last_add_to_cart); // is 1234
EDIT: When I var_dump the $session before the redirect everything is ok
-
Thanks guys!
I used Batcher before, but I really have to have a closer look at Adrian's module.
- 1
-
Hi all
All I could find was the opposite of what I need, how to unpublish a page via API. But I need to publish 500 pages. Those pages are children of/inside a PageTable field … don't know if this matters.
Anyhow, I tried to loop through the child pages and publish them. But even one doesn't work … it just stays unpublished
// Pagae 2603 is my page with 500 unpublished children if ($page->id == 2603) { $fcp = $page->children('status=unpublished')->first(); $fcp->removeStatus(Page::statusUnpublished); $fcp->save; // foreach ($page->children as $c) { // … // } }
There is no such method like publishPage?
-
Robin, thanks for that! Indeed this one works differently. It feels a bit off the road using the wire('pages') instead of wire('users), but that would work as expected.
But again, this is quite against the "everything is a page" mantra in PW. However, I will include a status!=unpublished in the selectors.
Thanks again!
-
I am wondering why this one
<?php $tsubscribers = wire('users')->find('template=user'); foreach ($tsubscribers as $ts) { echo $ts->email . '<br>'; } ?>
will include unpublished users as well. The docs say https://processwire.com/api/selectors/#access_control
Pages with hidden or unpublished status will not appear in the results from database-querying selectors that can return multiple pages (i.e. functions that return the PageArray type). For instance $pages->find("..."), $page->children(), etc.
The site is running PW 2.7.2 … is this only new to PW 3?
I had all users unpublished and see them as unpublished in the back-end. But when selecting users via API the unpublished are included as well. I have to add status!=unpublished to opt them out.
-
I would like to handle Server-Error 410 (gone) the same way like PW handles 404. When I add to my .htaccess "ErrorDocument 410 /index.php" and create a /http410/ in the back-end that doesn't seem to be enough.
While I could point it directly to /http410/ I am wondering if the other way is possible as well?
-
Got it. There was a Redirect after a setting a cookie
Damn
- 2
-
The last days two new sites went online and both got a SSL certificate installed.
But one has a HTTP problem, although both are configured the same (seem to be). When I run
curl -I -L https://www.example.com/
it gets redirected to itself again and again. I had a HTTPS redirect in my .htaaccess but have removed it. The home template was configured to use only HTTPS but is now configured to accept both. If I change that to HTTP only, I get and error.
The origin must come from PW, because all files not processed by PW don't have the redirect problem.
I had a look at the /site/assets/cache/ folder but don't know what to delete. And there is a cache table in the DB as well. Don't know either if I can just delete its entries.
Apache 2.4.18
PHP 7.0.11
PW 3.0.42
No dedicated cache installed, no cache activated in PW -
-
Thanks both of you!
Where do I find that option?
I am using 3.0.42 and can't find that option.
-
I have configured some template to be not movable, so the editors can't move them around. But actually I need to move them with the API. Is there some way to avoid the error
Pages using template 'order' are not moveable
-
I included the PW index.php in a script file and need to return a full URL of pages (autocomplete Ajax response)
However, the file is located on another host and I get the wrong URL
ajax.example.com/public/search_autocomplete.phpI am wondering why ->url and ->httpUrl is /public/found/page/ or ajax.example.com/public/found/page/ instead of /found/page/ or example.com/found/page/ … and how to get the proper URL. Do I need to set the $config->httpHost again or something else?
<?php namespace ProcessWire; header('Access-Control-Allow-Origin: *'); error_reporting(-1); include '../../../www/index.php'; $q = wire('sanitizer')->selectorValue( wire('input')->get('q') ); $results = wire('pages')->find('title%=' . $q . ', template=basic-page, limit=10'); $array['query'] = $q; foreach ($results as $result) { $array['suggestions'][] = ['value' => $result->title, 'data' => $result->url]; } echo json_encode($array);
-
Thanks for your quick response! I looked in Captain Hook and saw …
#1280: public function ___added(Page $page)
… but didn't noticed it was in the Pages section. Had just seen Page $page.
Anyhow, the code above works great. I only need it for pages created in the CMS backend.
17 minutes ago, LostKobrakai said:if you add pages as part of any other page
I guess you mean front-end pages (template), right?
-
Hi all.
I have to set default values for some fields (page select and text fields) on my page. I think the /site/templates/admin.php is the appropriate place? But I can't get anything to work from there. That is my current code, that looks to me like it should work. But it doesn't
wire()->addHookAfter('Page::added', function($event) { wire('page')->setAndSave('page_select_field', 1042); wire('page')->setAndSave('text_field', 'Default Value'); }); require($config->paths->adminTemplates . 'controller.php');
-
Yeah … maybe I'll give it a try. Had just a short look into the code, don't know if I understand everything And that could be the bottle neck, if I need to update it somewhen
- 1
-
Ha ha guessing isn't a good habit when programming.
However, I just checked and this code will have my system user as created and modified
$c->created_users_id = $this->systemUser; $c->modified_users_id = $this->systemUser; $c->save(array('quiet' => true));
- 1
-
Thanks guys!
created_users_id works great … so I guess modified_users_id will work as well
-
I cam across this issue a long time ago. When I create a page via API that page is always "created by" the guest user.
I tried to add a dedicated user or the admin, but had no luck. Perhaps that field is – like created date – not API-able.
$c = new Page(); $c->createdUser = wire('users')->get('name=admin');
Although I know that some fields won't be editable via API, I think this one is really confusing. For example, the first time I noticed this, was a client of mine, who nervously reported there is a protected page created by "someone from outside". It took me a while to get behind it :-D
-
Thanks Wanze! I had a look at it, but I think I will develop something on my own. I am always in worries when using 3rd party plugins for a vital part of my website Especially if it is not "easily" exchangeable.
-
Thanks Can.
I knew that already. I was wondering how it works. The brief description in the config is a little less to know about it.
I need to go a step deeper I think, because the files I am going to protect are for specific users only (billing PDF)
-
I couldn't find much about the pagefileSecure option. Is this just a runtime setting I can switch on or off anytime? Or is it only for files uploaded later? Is there anything changing in the files/assets folder?
-
That would be my next choice Thought it may be possible by core. I'll have a look at it.
-
I am wondering if it is possible to hide a field depending on the PageTable field.
I would like to hide a field when the PageTable has any child-pages saved (or show only, if there are no pages saved). But I couldn't figure out how or if it is supported at all.
product_variations.count!=0 // … hides it in any case product_variations='' // … hides it in any case
How to optimise site search?
in General Support
Posted
HI all.
I recently built a web shop with PW and it works pretty good. I love the simplicity and freedom working with templates and how stuff works and the client loves the back-end.
However, the part I am unhappy about is the site search. Beside the API selectors work fine, it seems not be suitable for that kind of search. People search for words, phrases, they mix spaces, hyphens etc., add measurements … so a lot of searches end up in 0 results.
I know of the ElasticSearch module and other external things like Sphider, Google CSE, algolia.com … but some are quite complicated and limit my control or bring google's ads on the site
So perhaps you have any improvements, ideas how to get a better search engine on my website. Most problems come from spelling issues, singular/plural, hyphenated words/searches.