-
Posts
7,479 -
Joined
-
Last visited
-
Days Won
146
Everything posted by kongondo
-
My guess...Blog was installed without the demo content option (i.e. 'Blank Template Files' option was selected), so, no output
-
Glad you like it. What Mike said .
-
I suppose so. I struggle with the ML API to be honest and could do with some help. Do I tell PW to get the page (menu) with the title of the default language? Thanks for any pointers/code, ta.
-
Ahem...really Mike? ....the docs, Mike, the docs: Glad you got it sorted .
-
Hi @Zeka, Yeah, PHP 7 is a little more stricter. PHP 5 forgave such indiscretions . If you could open a bug report for me so that I don't forget to fix it, I'll appreciate it (along with other issues that have been recently reported). Thanks.
-
Gallery: A photo album module (preview)
kongondo replied to kongondo's topic in Module/Plugin Development
Both. A free (and decoupled from the back) frontend module and a Pro backend. -
PW 3.0.76 – Login/Register/Profile, ProCache, Uikit 3
kongondo replied to ryan's topic in News & Announcements
I can categorically assure you that this is not the case. Support or lack of support for a module is not a criteria for what modules make it to the core. I could go into details but I need to run. -
What @abdus said. Here's another link to to the docs on internationalisation in ProcessWire.
-
OK, so I had a stab at this using $cache and ready.php. It seems to work fine. Throw the following code in ready.php or similar...The code and in-line comments are purposefully verbose to make it easy to follow. // Hook into login/logout sessions wire()->addHookAfter('Session::loginSuccess', null, 'checkLoggedIn'); wire()->addHookBefore('Session::logout', null, 'removeLoggedIn');// Hook before to get $user->id /** * Check if a user is already logged in * * If user logged in, take an action (notify,logout,etc). * Else, cache user as logged in to check for duplicate logins. * * @param HookEvent $event The object (Session::loginSuccess) we are hooking into. * @return void * */ function checkLoggedIn(HookEvent $event) { $user = $event->arguments('user'); $session = wire('session'); $userDuplicateLogin = checkUserDuplicateLogin($user);// returns boolean // if user logged in, do something. Here, we log them out and redirect to home page // you could make an exception for Superusers, or exception by role, permission, etc if($userDuplicateLogin) { $session->logout(); $session->redirect('/'); } // set cache else setLoggedInUserCache($user); /* @note: testing only $log = wire('log'); $log->save("user-logs","Successful login for '$user->name'"); */ } /** * Check if a user is logged in more than once. * * @param User $user The user to whose logins to check. * @return Boolean $duplicateLogIn True if user already logged in, else false. * */ function checkUserDuplicateLogin(User $user) { $cache = wire('cache'); $duplicateLogIn = false; $userID = $user->id; $cachedUsersIDs = $cache->get('loggedInUserIDs');// array OR null if(is_array($cachedUsersIDs) && isset($cachedUsersIDs[$userID])) $duplicateLogIn = true; return $duplicateLogIn; } /** * Create or update cache for logged in user. * * @param User $user The user whose cache to set. * @return void * */ function setLoggedInUserCache(User $user) { $cache = wire('cache'); $userID = $user->id; $cachedUsersIDs = $cache->get('loggedInUserIDs'); // cache does not exist, create empty array ready to cache if(!count($cachedUsersIDs) || is_null($cachedUsersIDs)) $cachedUsersIDs = array(); // save/update cache // for value, can use whatever, even $user->name; doesn't matter, key is the important thing here // outer array: we use $user->id to group same user; // in inner array, we use session_id() to ensure uniqueness when removing cache $cachedUsersIDs[$userID][session_id()] = $userID; $cachedUsersIDsStr = json_encode($cachedUsersIDs);// JSON to save as cache $cache->save('loggedInUserIDs',$cachedUsersIDsStr);// @note: set expiration of cache if you wish to } /** * Remove a logged out user's cache. * * This to allow subsequent logins. * * @param HookEvent $event The object (Session::logout) we are hooking into. * @return void * */ function removeLoggedIn(HookEvent $event) { $user = wire('user'); removeLoggedInUserCache($user); /* @note: for testing only $log = wire('log'); $log->save("user-logs","Successful logout for '$user->name'"); */ } /** * Remove the cache for a user who has logged out. * * @param User $user The user whose logged-in cache we are removing. * @return void * */ function removeLoggedInUserCache(User $user) { $cache = wire('cache'); $userID = $user->id; $cachedUsersIDs = $cache->get('loggedInUserIDs'); // cache does not exist/empty, nothing to do if(!count($cachedUsersIDs) || is_null($cachedUsersIDs)) return; // save/update cache // @note: we check for current logged in user but we remove the whole user group (outer array) // this is because the user logged in 'validly' is logging out. if(isset($cachedUsersIDs[$userID][session_id()])) unset($cachedUsersIDs[$userID]); $cachedUsersIDsStr = json_encode($cachedUsersIDs); // save updated cached $cache->save('loggedInUserIDs',$cachedUsersIDsStr);// @note: set expiration of cache if you wish to }
-
Maybe how PW checks if the same page is being edited in a different window could be of help? Have a look at the method checkProcessKey() in SystemNotifications module.
-
Fieldtype not found after installation of site profile
kongondo replied to Robin S's topic in General Support
I get the "FieldtypeXXX" does not exist as well...during regular login. I always assumed it was due to my setup. I symlink my modules folder to be shared amongst a 2.7 multi-sites site, a normal 2.8 and normal 3.x installs. However, I also see it sometime on a machine with 3.x only. I'll try to keep an eye on it. -
Thanks for reporting @Tom H. Looking into it.
-
Splitting field content to parts and showing them in divs
kongondo replied to MilenKo's topic in Getting Started
Not what you asked, but assuming that you will be using these (or their variants) nutrition name, quantity and measure over and over, typing them in a textarea field and using some regex magic to split them up is probably not the better solution. In addition, typing the stuff up every time is tedious. I'd go for page fields or fieldtype options, or better yet, since you are grouping items, repeaters or even better repeater matrix or table combined with page field (for nutrition name) + integer (quantity) + fieldtype options or page field (measure). The latter modules are paid modules but well worth the spend. Using this approach, not only do you throw out the need to use regex, you also get the benefits of a clear presentation, user friendly/easy to edit, easy to add and remove items, searchable items, etc. -
Multi-Site, adding entries into index.config.php
kongondo replied to swampmusic's topic in General Support
Cool idea! But it seems the requirement is also to automate the process? -
Multi-Site, adding entries into index.config.php
kongondo replied to swampmusic's topic in General Support
I haven't looked at your code closely, but if you need to write to a file, you need to write to a file. You have file_put_contents and fwrite. I see no other way around it irrespective of the software you use. ProcessWire itself writes to /site/config.php/ during install. I use this multi-site setup myself. I've been meaning to write some code or a module to automate the process but never got round to it. You could do with some error checking and backing up the original file as part of the updating the file. -
Does add() from API automatically save() the page ???
kongondo replied to celfred's topic in General Support
@Zeka, that's a different method. That add() is for adding a new page to a specified parent and assigning it a given template. The add() @celfred is referring to is the WireArray method documented here and as seen here. It adds an item to the end of a WireArray (and its derivatives, e.g. PageArray). @celfred It shouldn't add without a save. There's something funky going on in your code. It's hard to pinpoint where because we can't see the original code. Maybe there's some other save or $real is being overwritten somewhere. I've tested your pseudo function and it works as expected in both PW 2.7 and PW 3.0.71. If I pass $real as false, the $page is not added to the Page Field. Btw, though made up, this variable name will throw an error $new-eq -
Yes. Maybe your annual subscription expired?
-
Pages->get() works on every page except the page with the field
kongondo replied to bbb's topic in API & Templates
One trick is to do this instead... if('pageGeo' == $page->template) If you mistyped that as: if('pageGeo' = $page->template)// syntax error // OR even if(1 = $page->id)// syntax error PHP will throw a Parse Error: syntax error, unexpected '=' , immediately alerting you of your mistake . -
Gallery: A photo album module (preview)
kongondo replied to kongondo's topic in Module/Plugin Development
Welcome to the forums @kalimati Ha! It's the project I'm working on currently . So, hopefully soon. Meanwhile, there's also this module. -
Pages->get() works on every page except the page with the field
kongondo replied to bbb's topic in API & Templates
Only thing left to look at is your relevant template files code, the code in the include file as well as the settings of your page field (just in case). Any restrictions on who can view home page? -
Pages->get() works on every page except the page with the field
kongondo replied to bbb's topic in API & Templates
Strange one. I am wondering if some code is overriding $page when viewing the home page. Do other fields on 'Home' work fine? -
Pages->get() works on every page except the page with the field
kongondo replied to bbb's topic in API & Templates
Works fine here. What does debug and/or Tracy tell you is the value of $footer_items when viewing the home page? Maybe there's some template level restriction? -
@SwimToWin Moderator note: I understand the concern of topics becoming too long (and it is something we are looking into), however, I am afraid we do not address the issue in this manner, i.e., by starting other topics in other places. This is MarkupSimpleNavigation's support forum, hence, it is the correct place to discuss your issue. Thus, I have reverted your topic here.
-
Here you are getting the same image over and over. The image on the current page in the field blog_category_image. For your needs, maybe just skip your custom renderNav(). Maybe one of the following should fit your needs. // If showing all categories $categories = $pages->find('template=blog-category'); $out = ''; if(count($categories)) { foreach ($categories as $category) { $on = $page->blog_categories->has($category) ? ' on' : ''; $out .= "<li class='category-item{$on}'> <a class='category-box{$on}' href='{category->$url}'> <img src='{$category->blog_category_image->url}' /> <span class='category-title'>{$category->title}</span> <span></span> </a> </li>"; } } echo $out; ######## OR ######## // If showing only the current post's categories (no need for 'on') $categories = $page->blog_categories; if(count($categories)) { $out = ''; foreach ($categories as $category) { $out .= "<li class='category-item'> <a class='category-box' href='{category->$url}'> <img src='{$category->blog_category_image->url}' /> <span class='category-title'>{$category->title}</span> <span></span> </a> </li>"; } } echo $out;