Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/20/2017 in all areas

  1. Welcome here, @pwuser1! You made the best 1st step you could - found this amazing community and one of the best php products out there (with super cool inline docs) . Start a project, solve problems as they come, read the code. This is the way PW changed me from knowing almost nothing to knowing some of it. I am sure you will become much more advanced following the same route though. Good luck! I am sure you could find tons of advice on the Internet, so not giving any generic one. But just for the count here are some links to relevant forum topics: PHP js ...but really tons of it here and elsewhere) By the way, if you want to find something on this forum (like the fact that this question was raised so many times), use special google search like this one I made for myself. Good luck!
    7 points
  2. Soma has the délicatesse of Captain Hook when he gets annoyed
    4 points
  3. @Ivan Gretsky / @Pete, Perhaps there should be a pinned item on the Getting Started section? Only took me two and a half years lol ...
    4 points
  4. @FrancisChung, when I came here someone introduced me to this google search trick. It was some discussion it has to be the default one for the forum search box. But it did not happen (due to some integration problems only @Pete knows about). So all the old-timers use it, as far as I know. Personally I almost never use the in-built search (only when I need to limit the search by thread, but that's rare). Let this topic be a reminder of such a useful tool to learn more from PW forums!
    4 points
  5. On the search front, I don't forget that Tracy has a built-in search that lets you choose what part of the site you want to search. It's a shortcut to that Google site search, but modified to the area you choose.
    2 points
  6. if(!$session->get('flag'){ echo 'New visitor'; $session->set('flag'); } else { echo 'Been here a while'; } Completely untested but can't think why it shouldn't work.
    2 points
  7. +1 for the search, Ivan. @pwuser1, the best way is to just get your hands dirty and build some websites that require php/js or both. That's what I did with almost no knowledge of either. Sure you'll get stuck a few times along the way, but that's what the community forum / Stackoverflow / Google/ Ivan's awesome search is for ...
    2 points
  8. Agreed, that's one reason why I'm working on this (where it will be possible to choose the local profile or to download one from a given URL):
    2 points
  9. Too many copywriters out of a job? I have a hard time getting clients to write 300 chars on the whole page, let alone the meta description.
    2 points
  10. Pagetree Add New Child Reverse New Pages in Descending Sortorder (newest first) while sortmode can be "Manual Drag-n-Drop" When a site display an overview of the latest posts, news, image-albums, etc. the newest entries should be on top of the list. We can achieve that by using an automated setting for the sortfield e.g. when the page was created = "-created". But this way we are not able to manually move a single page in the tree. This module enables us to do exactly that. It works with manually created pages, with pages created via the API, also when bootstrapped by importer scripts. Pagetree "Newsitems" with 3 newsitems sorted in descending order. New created item 4 is added to the top. To change the order click item 3 and drag it to the top and drop it. How to use it Download the module into your site/modules/ directory and install it. In the config page you find a single textarea field. Here you can enter the templatename or page-ID of the page which children should get reverse added, - optionally followed by a comma and the child-templatename if you need a more precise selector. You can add as many parents as you like, but only one on each line and in this format: TEMPLATE-NAME or PAGE-ID[,CHILDTEMPLATE-NAME]. A few examples: newsitems posts,post 1042 1033,album You want set your template(s) sortfield(s) to 'Manual drag-n-drop' if not have done already. ATTENTION You need to setup the TreeParent and the module config when there are no children in it! Otherwise it will not work! Also disabling the module once you have added children and then add one new page to it will mess up all! (You may think about to install the module as permanent in critical situations.?! see below ->) If you need to install it in a site for an already existing branch, you can do it this way: move / rename your existing branch create a new (empty) branch with the original name move your childpages into the new branch remove the renamed (and now empty) old branch DOWNLOAD - Version 1.0.2 get it from the Modules Directory Want to make it bulletproof? If you are concerned that the module settings could be dropped by other users or that the module itself could be uninstalled by accident, you may edit the module file directly: add the settings to the class constant permanentValue uncomment setting for permanent in the ModuleInfo This way the permanent settings couldn't be dropped by accident. To change it you first need to edit the modules file again. Example: You have two settings in the inputfield of the modules config, without permanent setting: parenttemplate1,childtemplate1 parenttemplate2,childtemplate2 Now you want to have the the first setting become bulletproof permanent: a) you enable the setting in the getModuleInfo, (uncomment setting for permanent) b) you write your permanent settings under the constant permanentValue const permanentValue = "parenttemplate1,childtemplate1"; After both steps, the module cannot get uninstalled anymore (Step a), and the first setting cannot get deleted anymore (Step b), as it is recreated with every call of the configscreen. (See first code line of method getModuleConfigInputfields) If you want to keep both definitions permanent, write them separated with a newline character "\n" : const permanentValue = "parenttemplate1,childtemplate1\nparenttemplate2,childtemplate2"; History of origins create pages via API, how add to the top of tree? Create new child as top sibling rather than bottom? New page on top? Pin Page to Top of Page Tree? move and sort pages with the API
    1 point
  11. Hey guys, some light reading: https://supertiny.agency/en/blog/how-secure-is-your-website/ This discussion pops up from time to time, and this is something I usually point out every time I show PW to a new client, so I thought it would be nice to write a permanent post on the subject. Enjoy.
    1 point
  12. The easy way to do this is to compare the current JSON reply to the previous one. If an entry exists in the previous JSON reply that doesn't exist in the current JSON then you know that you need to delete the corresponding entry in PW. Storage is easy - just write the JSON to disk. Compare is easy - convert the two JSON feeds to arrays and just do an array diff. Delete is easy, as long as there is a unique field in the JSON that maps through to a unique field value in PW. Once you've processed the current deletions, just store the JSON ready for the next cycle.
    1 point
  13. Update: Blog 2.4.2 As of today and this version onward, ONLY ProcessWire 3.x is supported. Changelog Support for namespaced ProcessWire only (ProcessWire 3.x). All ProcessWire Comments Form Options can now be passed as as options to renderComments(). See the options here Available now in the modules directory. Please note that this version does not address any of the reported PHP 7.x issues.
    1 point
  14. Thanks @Soma - that helps. Looks like we are actually getting the same results - a miscount on my part - sorry about that! The reason of course for the extra one (now 801) is because Ryan added a new hook this morning: https://github.com/processwire/processwire/commit/87dc586c8c5d3435db8badcfbec7e9779e2b7f55#diff-bf4ce11deee917bffc99d4efcc9f72f1R2291
    1 point
  15. I thought we were working together to try to improve your Captain Hook sheet here. I guess the difference is that you can easily install Tracy, whereas I can't replicate exactly what you have at your end. That said, if you could send me a json_encode()'d version of $hooks, I can do a diff on the output you have vs what Tracy outputs. Maybe it's a bug in my script and I would like to improve it for everyone's benefit. Thanks.
    1 point
  16. ... Of all hookable methods that are executed. So when you save a page you would see all methods you can hook into in the right order... Save, saveready, saved...
    1 point
  17. HAH! Of course! That will definitely work.
    1 point
  18. That's not true and an unfair statement in this context. I agree that "no listed vulnerabilities" is no proof of security but it does also not mean that security is not a main goal. Security by obscurity definitely helps to protect us from lots of threats but it's definitely not the only and also not the most important part of the puzzle... https://processwire.com/docs/security/
    1 point
  19. Thanks adrian. I've never really used the debug tools as I didn't find them really helpful. Maybe I'm missing something and just don't know how to use them properly? But what I wanted to achieve with the hookrecorder was some kind of execution plan of all hookable methods. A list where you can see which method get's called after the other. Ideally it would also show some additional information (like which page was saved, wich arguments where provided...). Maye it would also be possible to have some kind of nesting in it? The result could be something like this: ProcessPageView::execute ProcessPageView::ready ProcessPageEdit::buildForm (id=mypageid, ...) InputfieldWrapper::render (name=myfield, ...) Inputfield::render (name=myfield1, ...) Inputfield::render (name=myfield2, ...) Inputfield::render (name=myfield3, ...) ProcessPageView::finished I have no idea if that Execution Plan is correct... I'm quite familiar with hooking all around and looking for the right hook in the code but still I don't know exactly WHAT is going on WHEN. But looking on sime kind of list like above everybody would instantly get what is going on and would get a tremendously better understanding of how pw works. Then one could go further and look into the related class' code and inspect it. This list could also show additional info, as I already mentioned. And what I mean is on the one hand information about some variables what is currently happening (like which field is going to be rendered etc.) and on the other hand maybe it could list all hooks that are currently applied to this method (similar to the hooks list of the debug tools, listing hooks by priority so that you instantly get an idea of what is going on). I think such a tool would not only be of HUGE help for newbies but also for experienced devs. For example you could have a problem with some kind of pagesave actions... you have a hook that should change the page title to "myval" after every pagesave... Pages::save (id=123) execute hook from file /site/ready.php on line 12: collapsed hook code [...] $page->title = 'myval'; [...] Pages::saveReady (id=123) execute hook from file /site/modules/mymodule.module.php on line 240: [...] $page->title = 'my wrong value'; [...] Pages::saved (id=123) no hooks executed you would instantly see what's going on and that there is a conflicting saveReady hook overwriting the page title. I hope you get my point now. Or maybe I should start using XDebug and that's exactly what it is doing? PS: The list of hooks we have in the debug tools seems to be a list of all active hooks? And the sorting order is not helpful for me - it is even confusing... Is there any system in the order they are presented?
    1 point
  20. Do you get the actual message though? $message = $input->post->message; $message = "There is a message from {$name} with the email {$email} The message is: '{$message}'"; It looks like you're taking the message from the field, then overwriting it, so it'll always be the same, just with a different name and email. What about the actual message they wrote? Just tested this and $message does actually get included in the new variable. I thought it would be overwritten. Ignore that last bit :-p There is also a difference in how single and double quotes work in PHP, that may explain why you're seeing the html tags. https://stackoverflow.com/a/3446286
    1 point
  21. It would be nice if the installer treated site profiles installation like module installation. Currently it will pick up any profiles in the appropriate directory, and I use the export site profile module to create my own for reuse. Modules work this way too by scanning the modules directory, but also offer the option to install by providing a module class name to download from the official modules directory, a URL, or an upload. Of course modules are installed like this after the base Processwire installation is already configured, whereas site profiles need to be chosen at install time, however if functionality were similar for site profiles, this would allow for both offline and online installation, and allow the included profiles to be kept to a bare minimum.
    1 point
  22. @Monty, Welcome to the forums Simon. I've merged your other thread here as your two threads are about the same thing.
    1 point
  23. Thanks for the note. I'm not sure, looks like while editing the module entry the download url got fu. There was just a number. I corrected that and it seems to work again? Not sure how the download url field can be a number only and if you clicked download on the module page you got to page not found...
    1 point
  24. Hi @Soma, When I try to upgrade to the newest version of the module using https://github.com/ryancramerdesign/ProcessWireUpgrade, I get the following message for some reason. Session: Invalid download URL specified I've tried on several sites. Not sure what is wrong?
    1 point
  25. Hi all! Sorry I'm little late for the party. Key validation on every page load is surely not necessary and it was just a simple stupidity be set like that. It's fixed now and I just pushed it to github. Thanks for the notice! (not been using the module after couple of tryouts)
    1 point
  26. Interesting read - https://moz.com/blog/how-long-should-your-meta-description-be-2018 TL;DR 300 chars, up from 155
    1 point
  27. Hey @bernhard - I'd be happy to implement this in Tracy. But first, I think I need to better understand exactly what you want to see in the output. Have you looked at the "Hooks Triggered" section of the Debug Mode panel? That is called on each page request. What additional information would want to see. Sorry, I feel like I am not quite fully getting it yet. Thanks!
    1 point
  28. you just have to use a regular multi select, and then init that with the chosen JS on your form; In other words you wouldn't setup the formbuilder field to use chosen select, you would setup a page select multiple with a InputfieldSelectMultiple as the input; then you would config add the chosen assets from within your formbuilder.inc file in your templates folder, using either a conditional or a switch statement; you would also need to add a init js file that would init the inputfield.. (see https://harvesthq.github.io/chosen/ for examples)
    1 point
  29. but @heldercervantes has not said any lie there .. you know any security issue? .. If not, then PW is the safest until proven otherwise
    1 point
  30. @SamC it's really as simple as that: https://processwire.com/blog/posts/new-ajax-driven-inputs-conditional-hooks-template-family-settings-and-more/#new-conditional-hooks Update 2022: $wire->addHookAfter('Pages::saved', function(HookEvent $event) { $page = $event->arguments('page'); bd('page saved'); bd($event, 'event'); bd($event->object, 'event->object'); bd($event->arguments(), 'event->arguments'); }); in the beginning it can be a little confusing when to use event->object, event->arguments and event->return but with the help of tracy you can quickly bring light into the dark: add the code above to the tracy console, set the radio on the right to load it on "ready" (same as placing the code in the site/ready.php file) and save any page: $event->arguments('page') is the same as using $event->arguments(0) that you will see very often and in the tracy dump you see that 0 is simply the key for the first argument in that hookevent. you can also collapse the "data" property of the hookevent and you would see the same: You can also use your IDE to quickly find what the HookEvent is returning/containing in which hook. Let's take the common saveReady hook as an example: We know that the hook is attached as Pages::saveReady (eg because we have read that somewhere) That means that the hook is part of the "Pages" class, which is located at "/wire/core/Pages.php" - that's easy to find out using CTRL+P in VSCode: Searching for "___saveReady" lets us find the corresponding method: Now we see, that we have ONE "arguments", being Page $page - this means $event->arguments(0) would return the page being ready for saving $event->object would be the class, here "Pages" $event->return is the return value of that method, here $data (line 1739) Edit: There's some additional explanations in this post: https://processwire.com/talk/topic/27248-pagestrashtemplatefoo-vs-pagestemplatefootrash/?do=findComment&comment=224659 #search afraid of hooks
    1 point
  31. Inside a hook in admin.php, you have to use $this or wire() to return an object. So $this->fields->get("sport_categorie"); will return your field. About the option field, look at the following code : $this->addHookAfter('Pages::saved', function($event) { $page = $event->arguments[0]; //set the page if($page->template == 'sport-verenigingen-overzicht') { //get the subcategories from the parent textarea, split on newline $subcats = preg_split('/[\n\r]+/', $page->subcats); //(also tried without imploding and adding the array, also doesnt work) //$subcats = implode("|",$subcats); $subcats = implode("\n",$subcats); //get the children $children = $page->children(); foreach ($children as $child) { //set the options(sport_categorie is the options field) //$child->sport_categorie = $subcats; //$child->save('sport_categorie'); $field = $this->fields->sport_categorie; $this->modules->get('FieldtypeOptions')->manager->setOptionsString($field, $subcats, true); $child->save($child->sport_categorie); } //if i use a normal textfield instead of an optionsfield, //all the children have the correct data e.g: test1|test2|test3 //how to get the values into the options field?? } });
    1 point
  32. If it's any consolation, it's not that great in PHPStorm either. I think I will setup a similar forum topic for PHPStorm users to vent their frustrations and workarounds.
    1 point
  33. Hope you're still enjoying Windows 3.1 then Sorry I couldn't resist ... ha ha ha - not really very funny I know We are obviously getting way OT, but I guess the key thing for me is that there is now an option with $pages->sort() to easily add reverse order functionality after a site is already set up if we decide it would be a better UX. I like having options!
    1 point
  34. Seems like the main problem is that the setKeyAndValidate() method is called on every PW ready(). I just commented that out and load times go back to being normal. I don't know the Tiny API, but I would think it would be possible to either just do this once, the first time the API key is entered, or perhaps if it's needed for each call to Tiny, then it could be called only when one of the hooks is triggered. Perhaps @Roope can take a better look since it's his module.
    1 point
  35. Hi @dragan, Thanks for replying. Got it fixed by uninstall one of the modules. Gideon
    1 point
  36. Came across this issue today when trying to push a PW installation to an AWS server running PHP 5.6.29 on CentOS. File uploads weren't working with the same getConfigData() error, and front-end image sizing was delivering the same error. Turns out php-gd wasn't installed by default. Running sudo yum install php-56gd fixed it for me.
    1 point
  37. New line starts after 100%. 33+33+33=99% so the next one tries to fit within that last 1%. But there is not enough space so it floats into a new visible line. Then the "real" new line starts but repeats again. This is just default CSS behavior;) Make two columns 33% and give the third one 34% to fix this. No one will notice the 1% difference.
    1 point
  38. Can you try with 33% 34% 33%? That's what I use and haven't had an issue
    1 point
  39. Security by obscurity. That's where ProcessWire is currently in.
    0 points
×
×
  • Create New...