Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/19/2021 in all areas

  1. I hope everyone is having a good week! Commits to the core this week include 10 issue report resolutions (so far). This will likely continue next week as well, and then I'll bump the version up then. Also included this week is an CKEditor upgrade from 4.14.0 to version 4.16.0. While that may sound like a minor CKEditor version bump, there's actually quite a list of updates in the CKEditor 4.x changelog, including a few security-related fixes, though none that I think are likely to affect PW users. I do still have a couple of core feature requests in progress as well, but there's more work still to do on those. Nothing too exciting this week, but I like to check in and say hello either way. I hope you all have a great weekend!
    18 points
  2. And we love hearing from you. Have a great weekend everybody.
    6 points
  3. corporate.blue-tomato.com is a new Website about the Corporate behind Blue Tomato. You can find informations about the history and values of Blue Tomato and also all open job positions. Used Modules ProCache ProcessGraphQL (used with React on the job overview page for searching/filtering the jobs) ProFields: Combo ProFields: RepeaterMatrix (Used for some kind of a "PageBuilder") SeoMaestro TemplateEngineSmarty / TemplateEngineFactory
    6 points
  4. Hi guys, I just found this article on A List Apart: https://alistapart.com/article/webwaste/ Here is a quote: After reading this, I have to rethink my design strategy for my future websites.
    4 points
  5. this is why I for one only make websites that no one is ever going to look at anyway.
    3 points
  6. v0.2.5 released. In this release stub files will always be created in and deleted from an "AutoTemplateStubs" directory and you can choose where this directory will be created. This avoids the risk that somebody accidentally configures an existing unrelated directory as the stubs directory. Please update to this new version for safety's sake.
    3 points
  7. The page name also seems to work: $pages->find('images.tags=the-page-name') And in case it's not obvious, you can also find the page(s) used in the Page Reference field in a separate step and then use that Page/PageArray in the selector because it will be converted to ID(s) when treated as a string. // Find the tags you want to search for $search_tags = $pages->find("template=tag, title=blue|green"); // Find the pages with these tags in the images field $results = $pages->find("images.tags=$search_tags");
    2 points
  8. Hi, My name is Marvin, and i want to ask about a processwire, i'm new at processwire, and want to learn make a website using a php and processwire, but i have a problem. My problem is, when i want to uploading an image file, and a document file like a pdf, or doc, but every time i upload it, my image didn't upload to the back-end, just doc file was uploaded to the back-end. Any suggestion where i was wrong? Thank you NB : i attach my code below This is for uploading process <?php $note = $note2 = $hidden =""; if($input->post->submit){ $upload_path = $config->paths->assets.'files/upload/'; if(!is_dir($upload_path)){ if(!wireMkdir($upload_path)) throw new WireException("No upload path"); } $original = $sanitizer->text($input->post->original); $indonesia = $sanitizer->text($input->post->indonesia); $other = $sanitizer->text($input->post->other); $composer = $sanitizer->text($input->post->composer); if(!$original || !$indonesia || !$other || !$composer){ $note = "Data tidak lengkap"; } else { $newFile = new WireUpload("song_files"); $newFile->setMaxFiles(1); $newFile->setOverwrite(false); $newFile->setDestinationPath($upload_path); $newFile->setValidExtensions(array('pdf','docx','doc')); $files = $newFile->execute(); if(!count($files)) { $newFile->error("No files received, so not creating page."); return false; } $newImg = new WireUpload("img_files"); $newImg->setMaxFiles(1); $newImg->setOverwrite(false); $newImg->setDestinationPath($upload_path); $newImg->setValidExtensions(array('jpeg','jpg','png','gif')); $images = $newImg->execute(); if(!count($images)) { $newImg->error("No files received, so not creating page."); return false; } $newPage = new Page(); $newPage->template = "files"; $newPage->parent = $pages->get("/files/"); $newPage->title = $original; $newPage->text_1 = $indonesia; $newPage->text_2 = $other; $newPage->text_3 = $composer; $newPage->of(false); $newPage->save(); foreach($files as $filename) { $filepath = $upload_path . '/' . $filename; $newPage->files->add($filepath); $newPage->message("Add file : $filename"); unlink($filepath); } $newPage->save(); } } ?> And this if for a form <div class="frow-container"> <form method="post" enctype="multipart/form-data"> <div class="frow mt-10"> <div class="col-md-1-1"> <a href="<?= $pages->get("/files/")->httpUrl ?>"><i class="fas fa-arrow-left"></i> Kembali ke Files</a> </div> <div class="frow gutters col-md-1-1"> <div class="col-md-1-2 mt-15"> <label>Original Song Title <input type="text" name="original"></label> <label>Indonesia Song Title <input type="text" name="indonesia"></label> <label>Other Song Title <input type="text" name="other"></label> <label>Composer <input type="text" name="composer"></label> <label>File <input type="file" name="song_files"></label> </div> <div class="col-md-1-2 mt-15"> <label>Youtube Video Code <input type="text" name="video"></label> <label>Audio Video Code <input type="text" name="audio"></label> <label>Image <input type="file" id="attach" name="img_files" accept="image/jpg,image/jpeg/,image/gif,image/png"></label> </div> <input type="submit" name="submit" value="Save"> </div> </div> </form> </div> Thank you very much for all help
    1 point
  9. On the Template Advanced tab you can set this option on "List of fields to display in the admin Page List" and write "{title}, {createdUser.name}"
    1 point
  10. Such an amazing website, makes me find a job there and move into Shetland ! :) Please let me know if any openings for a PHP/Processwire Dev in Shetland :)
    1 point
  11. A bit like this. Fixed the initial template to singular "product", its the same idea I just like it better this way ? <?php //Default selector to get ALL products $selector = "template=product"; // Get color and size variables and sanitize $color = $input->get->text('color'); $size = $input->get->int('size'); // I changed the approach here to append the possible parameters to the selector string. if($color){ $selector = $selector .= ",color=$color"; } if($size){ // See how this uses greater than or equal to $selector = $selector .= ",size>=$size"; } // At this point, if you have both parameters for the search, you'll have a selector like this: // 'template=product,color=blue,size>=10' $products = $pages->find($selector); ?> <form action="."> <select name="color"> <option value="red">Red</option> </select> <input type="text" name="size"> </form> <div class="products"> <?php // Render the products list foreach($products as $product){ echo "<div>....</div>" } ?> </div>
    1 point
  12. Just chiming in - I don't have a solution in terms of why the sessions are not clearing when you visit the Setup -> Sessions, but for me, going to Setup -> Sessions does clear the old sessions. The first time I realized this was an issue was seeing the number of records in the sessions table; once i cleared those, the database shed something like 50-100MB. I also read some of the other solution (involving the ini_set) and this didn't work - it seemed to make the site basically tank, and run really slow. ... and i guess my point was that this sessions not clearing in the DB is still an open issue, at this time..
    1 point
  13. Searching for values of page reference fields assigned to images is unfortunately not fully supported (yet?). All custom fields for an image are stored in the database as a single JSON string, so things get a bit tricky there and the regular subfield logic of PW doesn't work. What does work is searching for numeric page ids or full page paths. $pages->find('images.tagpage=1098') should work, as should $pages->find('images.tagpage=/tags/funny/'). $pages->find('images.tagpage.title%=tagtitle') won't work.
    1 point
  14. 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 }
    1 point
  15. You made my day Adrian !!! Working perfectly !!! Thanks very much.
    1 point
  16. Yes, that's true that you can't use $page inside a function, but the other thing here is that you already have wire('page') - there is no need to get the page from pages again, so this should be fine: $this->set('successMessage', '<h2 class="enviado-ok">' . wire('page')->mensaje_form_enviado .'</h2>');
    1 point
  17. I would try the session fingerprint config setting. Start by setting it to false and if that works you can try to make it more secure after that: https://github.com/processwire/processwire/blob/36984e4a057268b7a45b848e1b3b6ee757583459/wire/config.php#L241 Obviously make the change in your site/config.php file, not the wire one I pointed to.
    1 point
  18. Hi @laufi and welcome to PW. I think you'll be able to fix the problem by modifying the sessionFingerprint setting: This will show you the options, but remember that you shouldn't modify anything in the wire folder, so adding the option to your site/config.php file. https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/config.php#L184 0 or false will definitely work, but you may want to try another option if suitable.
    1 point
×
×
  • Create New...