Leaderboard
Popular Content
Showing content with the highest reputation on 09/20/2018 in all areas
-
6 points
-
http://php.net/manual/en/language.oop5.decon.php __construct() is called automatically. init() not. Every property defined/ populated with __construct() is accessible inside the class/ module and outside if public. If you define properties or change their values with init() you have no access inside a function of your class without calling init() from inside this function. If you init a module the processwire way inside a template you get what you expect. EXAMPLE <?php namespace ProcessWire; class TestModule extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => "Test Module", 'version' => 1, ); } public $colours = array(); public function __construct() { $this->colours = array( 'Blue' ); } public function init() { $this->colours = array( 'Red', 'Orange', 'Yellow' ); } public function getColourArray() { return $this->colours; } } If you call Module/ Class via ProcessWire or directly inside your template you will get different results: <?php namespace ProcessWire; // INSTANTIATE VIA PW var_dump($modules->TestModule->getColourArray()); // init() is called by PW // array(3) { [0]=> string(3) "Red" [1]=> string(6) "Orange" [2]=> string(6) "Yellow" } // INSTANTIATE CLASS $test = new TestModule(); // the PHP way, init() is not called var_dump($test->getColourArray()); // array(1) { [0]=> string(4) "Blue" } // CALL INIT AND CHANGE RESULT $test->init(); var_dump($test->getColourArray()); // array(3) { [0]=> string(3) "Red" [1]=> string(6) "Orange" [2]=> string(6) "Yellow" }5 points
-
Hey @teppo, the user 8-bit-guy is one of my sons favourites. My 12 years old son loves to work and hack retro hardware, like commodore 64 and a whole bunch of gaming handhelds or consoles, (besides others). Every third or second time, when he get something to work, and I ask him how he got it to work, he answers: "I found some useful information from the 8-bit-guy." ?3 points
-
Great read! A bit off topic (hey, this is the pub) but this is part of the reason why I love reading about old-school software development, and game development in particular. You know, when folks had to figure out how to run complex software while dealing with various limitations – such as being limited to something between 32 and 64 KB of memory in total. Good times. For the record, there are some awesome videos about old school development and hardware at YouTube by user The 8-Bit Guy. Not only does he clearly know his "old-school" computers inside out, he has also released amazingly polished new games for old hardware ?3 points
-
@patricktsg Make sure the template of the colour pages are enabled in the ProcessGraphQL module's config page and make sure user has explicit access to them in template permissions page. More on that here https://github.com/dadish/processgraphql#access-control3 points
-
It surely can be done. Although it would take some time. You can see a REST Api Module here https://processwire.com/talk/topic/20006-module-restapi/ Another option is to create a "Fake Woocommerce" site and use PW inside their handlers in order to save the data into PW. ?2 points
-
Yeah, go with: $p2->parent = $p so that you are referencing the page. Otherwise you are trying to find a page by name which actually doesn't work like that.2 points
-
2 points
-
I would guess this is down to row level locking in InnoDB over full-table lock in MyISAM. @Sevarf2 There is another option for handling a large number of simultaneous sessions: Redis. Your server sounds like it would be well specified to run redis too, though if it's now working well in production with InnoDB tables, I'd be tempted not to change it.2 points
-
2 points
-
Finally deleted all those pages using transactions: <?php namespace ProcessWire; include "index.php"; $dePages = wire('pages')->find("parent=/einstellungen/berufi/"); echo $dePages->count()."\n"; $i=0; try { $database->beginTransaction(); foreach ($dePages as $dePage){ echo $i++. " ".$dePage['title']."\n"; $dePage->delete(); } $database->commit(); } catch(\Exception $e) { $database->rollBack(); } Script took 7 Minutes to run , the actual query execution took about 7-10 seconds at the end of the script. I guess Transactions are helpfull at deleting pages too . What i did not try was to trash them first.2 points
-
LAPS, I am also using the LoginRegister module along with Kongondo Blog module, and wanted to add Favorite functionality for blog posts and users. This related thread gave me a good start: https://processwire.com/talk/topic/18618-best-way-to-handle-saving-an-item-as-a-favorite/ Guessing there will be more users than posts (and the pages may be sorted by favorite count in the future), I decided on using a page field "blog_favs" with input "templates : user" attached to my template "post". And I decided the Add/Remove functionality would be URL query based. Here is the code that I implemented in /site/Modules/MarkupBlog/MarkupBlog.module /** * Render favs * * Used by renderPostHead(). * * @access private * @param PageArray $blog_favs is field in blog_post template. * @return string $out Markup of favs * */ private function renderFavs($page, $small = false) { $options = $this->options; $out = ""; // if page field not available, break if ( !$page->blog_favs ) { return $out; } // if post display is summary snippet skip full UI // if user logged in, use full UI and functionality if ( $small != true && $this->wire('user')->isLoggedin() ) { $uid = $this->wire('user')->id; // uid is int $favExists = 0; // check query string for Add/Remove function $queryCheck = $this->wire('sanitizer')->entities($this->wire('input')->queryString); $queryAddFav = "add_fav={$page->id}"; $queryRemoveFav = "remove_fav={$page->id}"; $doSaveFav = 0; // on AddFav request, assume we are going to save fav $doRemoveFav = 0; // on RemoveFav request, assume we are going to remove fav if ( $queryCheck ) { if ( $queryCheck == $queryAddFav ) { $doSaveFav = 1; } if ( $queryCheck == $queryRemoveFav ) { $doRemoveFav = 1; } } // only loop through blog_favs if there are entries // only loop once if ( count($page->blog_favs) > 0 ) { foreach( $page->blog_favs as $fav ) { $fav_int = (int)(string)$fav; // convert saved object to string then to int (!) if ( $fav_int == $uid ) { if ( $doRemoveFav == 1 ) { $page->of(false); $page->blog_favs->remove($fav); $page->save('blog_favs'); $out .= "<div>" . $options['post_removed_fav_text'] . "</div>"; } else { $favExists = 1; } break; } } } // if AddFav, only if user not already faved this post if ( $doSaveFav == 1 && $favExists == 0 ) { $page->of(false); $page->blog_favs->add($uid); // $uid is int $page->save('blog_favs'); $favExists = 1; $out .= "<div>" . $options['post_added_fav_text'] . "</div>"; } // show Add or Remove links for user if ( $favExists == 0 ) { $out .= "<div><a href='{$page->url}?{$queryAddFav}'>" . $options['post_add_fav_text'] . "</a></div>"; } else { $out .= "<div><a href='{$page->url}?{$queryRemoveFav}'>" . $options['post_remove_fav_text'] . "</a></div>"; } } // always display basic UI Favorites Counter (this is at end to capture add/remove changes) $out .= "<span class='favs'>" . $options['post_favs_text'] . " " . count($page->blog_favs) . "</span>"; return $out; } I make no claims on performance or code elegance, but if any of this is helpful to you, enjoy!!!2 points
-
Some time ago I created a site profile for creation of a REST API with ProcessWire. Since I kept struggeling with updating stuff between different projects which use this, I decided to convert it into a module. It is now ready for testing: https://github.com/thomasaull/RestApi Additionally I added a few small features: automatic creation of JWT Secret at module install routes can be flagged as auth: false, which makes them publicly accessible even though JWT Auth is activated in module settings To check things out, download and install the module and check the folder /site/api for examples. If you find any bugs or can think of improvements, please let me know!1 point
-
I'd like to share with you guys our latest published project. This time a website for a German Food Photographer based in Cologne: http://www.elaruether.de/ Ela is an interesting case. Her relation with food started as a chef and evolved to blogging and later photography. She's now a professional food photographer. The only 3rd party modules that we installed were Admin on steroids and Tracy debugger (thanks to @tpr and @adrian for the continuous great work). Admin on steroids was particularly handy to invert the order of the blog posts and to add thumbnails to the portfolio pages on the admin: For the slideshows and project pages we used a heavy customised version of the excellent Owl Caroussel1 point
-
is Shopmaster ... by the way yesterday I bought a license for Padloper .. and I'll be ready for the new version ?1 point
-
"There are some bright spots indicating that improving over state-of-the-art is not impossible." The author is probably not aware of another excellent piece of high quality software which should also be listed: ProcessWire ?1 point
-
@josua118 Shooting in the dark: are you maybe doing something like <p><?php echo $page->body ?></p> ? You do not have to surround it with a p tag, simply use <?php echo $page->body; ?> instead.1 point
-
Hahahahaha, early morning support, sorry guys1 point
-
Or remove them. You don't need them in this case ?1 point
-
I see the same going on with imaging tools for backing up a whole partition on your computer. I tried Norton, Acronis, Paragon, etc. They are nothing but Corporate Bloat. And then there is this german programmer who made drive snapshot. I won't put any link here. I am not affiliated you can look it up your self with google. It's only 409 kbyte. Yes, thats right only 409 kbyte. You can install it, or use it portable or start it from a bootable iso. It blows away all the Corporate Bloat. So in addition to mr-fan's post, what I mean is it can be done, but somehow they won't.1 point
-
Hey josua118, and welcome to the forums! Quick question for you, how are you rendering the field on the frontend?1 point
-
That is strange, because Textformatters are only active on the frontend and not in the backend (far as I know). I never experienced a real slowdown with this module active and in use. Maybe it has something to do with your database access, because the module caches the embed code in the database. The module also works with multilanguage fields, as I am using it for that purpose on https://p-jentschura.com1 point
-
It's possible your method that tries to get the array is firing before init() has fired. The Module docs say: So __construct() fires earlier. Where you choose populate the array would probably depend on whether you need to get any custom module config at that point. If you don't need the module config then populate the array in __construct(). But init() is early enough for most cases too. An example: <?php namespace ProcessWire; class TestModule extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => "Test Module", 'version' => 1, ); } public $colours = array(); public function init() { $this->colours = array( 'Red', 'Orange', 'Yellow', ); } }1 point
-
1 point
-
From a core development perspective I'm going to agree with this – but while the core probably shouldn't include a pre-built, "full featured" page builder (at least for the time being, since no one really knows what the future holds), there's no reason why third parties should be discouraged to create such tools. I also know for a fact that there'd be a market for that ?1 point
-
Interesting that in this case InnoDB faster and yet there have been other issues where it's much slower: https://github.com/processwire/processwire-issues/issues/692 I am sure there's a good reason for it, but it does make the decision on which to use more difficult. Maybe MyISAM for most tables and InnoDB for the sessions table if you are using SessionHandlerDB?1 point
-
Lots of updates for the weekend ? I merged all updates of the dev branch to master and bumped the version to 0.0.8 I added a changelog here: https://gitlab.com/baumrock/FieldtypeRockGrid/raw/master/changelog.md I added an example filter + floating filter that you can easily copy and customize Regarding the filter: To apply this filter to one of your columns you just need to do this (full example here: https://gitlab.com/baumrock/FieldtypeRockGrid#create-custom-filters): col = grid.getColDef('title'); col.filter = RockGrid.filters.example; col.floatingFilterComponent = RockGrid.filters.exampleFloating; Here is the example filter implementing a "smart search": https://gitlab.com/baumrock/FieldtypeRockGrid/blob/master/plugins/filters/example.js It looks like this: Code with removed comments to see that it only 100 lines of code for your very own filter without limits (custom GUI, custom filter logic etc):1 point
-
A few things... With the axios call, try querying the relative and not the absolute url. Also, take note of the trailing slash on the url, sometimes that can trip you up depending on your template settings. Finally, you probably don't need to set the entire response to your Vue data object, with axios you are looking for response.data. axios.get('/ajax-actions/test-api/).then(response => (this.info = response.data)); If you need to keep the full absolute url, or if you are calling the api page from a different url, then look into CORS. Setting the header below on your template should be enough, depends on your setup (eg see this topic for issues with CORS when using procache). <php header('Content-Type: application/json,charset=utf-8'); header("access-control-allow-origin: *"); //... ?>1 point
-
You have several typos in your code. $searchResults = $pages->find("template=product")->explode(function($item, $i) { return [ 'title' => $item . ' - ' . $i ]; }); d(wireEncodeJSON($searchResults));1 point
-
Just very quickly... Not sure, but why would you want to? It's enough if you sit down and think about what kind of data you'll gonna need from PW. Then create appropriate JSON files that deliver raw data to your Vue.js app. You don't even need something like PageQueryBoss for that. Send a request from Vue to PW, do your usual $pages->find() or whatever, create an array, do json_encode(), set appropriate JSON-headers, and that's it. Frankly, haven't tried that. But you don't have to "mirror" PW users in your Vue.js app. Just send requests with credentials to PW, and return true/false and maybe add an HTTP header token for logins. For registrations, it's going to be a little more coding, but with PW's API, it shouldn't be too hard. Do you want to render/show PW's native page-edit view within that modal, or do you plan to re-create the whole page-edit functionality in Vue? I'd steer away from the latter, cause you'd be re-creating the proverbial wheel.1 point
-
That one looks really nice! First I thought I don't think ProcessWire is the right tool for such click-click-marketing sites, because its strength comes from the freedom of fields and querying them with the strong API, like $pages->find('template=xy,fieldx>50,fieldy<10'. But then I thought maybe it would be nice to have both combined. A site with custom templates & fields where we need more control over our data and an "ORY-template" (similar to the basic-page template) where the user can build its own totally flexible page. This could be great for landingpages. So if anybody has the time to build it - go for it ?1 point
-
You know what - given that I am not really the author of this logic, I think it's just an easy for you to take a look yourself (in the js file) as it is for me to explain it ? Sorry if that seems lazy, but I don't really have time to maintain this module beyond bug fixes etc - I just want to make sure the PW community has access to it.1 point
-
Great! Thank you Zeka. This CMS is great!1 point
-
http://www.viceregency.com/Translit.htm1 point
-
Then with a hook, you can remove them, look : On a module : $this->addHookAfter('LoginRegister::buildProfileForm', $this, 'renderProfileForm'); protected function renderProfileForm($event) { $form = $event->return; foreach ($form->children as $field) { if ($field instanceof InputfieldEmail || $field instanceof InputfieldPassword) { $form->remove($field); } } } or in ready.php : wire()->addHookAfter('LoginRegister::buildProfileForm', function($event) { $form = $event->return; foreach ($form->children as $field) { if ($field instanceof InputfieldEmail || $field instanceof InputfieldPassword) { $form->remove($field); } } });1 point
-
I usually go by @rafaoski's approach. I first go to http://www.favicomatic.com/, upload a 500x500 image to generate a full icon pack. Then I place the icons in their own folder inside the templates folder. Usually /site/templates/img/favicon/ Favicomatic gives you a rather large HTML snippet. Slap that on your template, and on each line that points to a file, you'll have to fix the url, like so: <link rel="icon" type="image/x-icon" href="<?= $config->urls->templates ?>img/favicon/favicon.ico">1 point