Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/26/2017 in all areas

  1. And now for something completely different - Tracy Debugger ProcessWirified! It's still in "alpha" (meaning spent only 15 minutes on it) but feels much better. Note the semi-transparent borders (no drop shadow), full-height header buttons and the PW colors (borrowed from the Reno theme).
    6 points
  2. You could use a hook to force a sort order on the Repeater field. See here: To prevent drag reordering you can use the Limit Repeater module: Not sure about opening a particular Repeater item when Page Edit loads - maybe have a look at the Repeater module code to see how the "Remember which repeater items are open" option is implemented. Alternatively you could use child pages instead of a Repeater for the band bios. This would allow you to define a sort setting for child pages of the band template in admin. Then use a RuntimeMarkup field to create: a list of modal edit links to the child pages, which will open about as fast as an ajax-loaded Repeater item a (truncated?) summary of the bio for the most recent child page an "Add new" button for easily adding a new child page
    4 points
  3. I just updated the Captain Hook cheatseheet to latest version 3.x now there's a master and dev version. Thanks to @owzim for providing a cli script to parse the repos automaticly and generate a array to use. It helps a lot to update. https://somatonic.github.io/Captain-Hook/index.html
    4 points
  4. Repeater rows pages do not have a title field ....,hence you not getting anything back. If you did the below, you should see something like ' 1482226910-677-1 ' $test = $pages->get(1156); echo $test->name;
    3 points
  5. @xavier. Glad it worked. Since a couple of ProcessWire versions back (I can't remember how far back, but since 2.7 at least), pages have a property 'published'. So: echo $page->published;// outputs the date when this page was published. Oh, am not sure you've been properly welcomed. If not, welcome to the forums .
    3 points
  6. Another update! There is now a "Toggle All" button which may come in handy if you want to search for a method (CTRL/CMD + F) to see the classes it exists in. Tip: search for "___save", rather than "save" so it doesn't find it twice on each row. Another update, unrelated to Captain Hook - now each panel in the Selector Panel has an info iconℹlinked to the relevant section in the "Introducing Tracy Debugger" blog post so you can get quick information about what each panel does.
    3 points
  7. If you haven't seen it already, check out the new Captain Hook panel in Tracy Debugger. If you have the Editor Protocol Handler configured you can jump straight to the hookable method in your code editor. Because the line links are generated from whatever PW version you are running it will always be correct. Pretty cool. Plus it includes the hookable methods in module classes!
    3 points
  8. Yep, of() is just a shortcut for the full setOutputFormatting() method.
    2 points
  9. Yeah, you will need something like this: $u = $users->get($sanitizer->username('username')); $u->of(false); $u->addRole("moderator"); $u->save(); You should have received an error that mentions specifically that you need to turn of output formatting. Do you have debugmode on and/or TracyDebugger installed?
    2 points
  10. @arjen I updated the README at https://github.com/gebeer/alpine-php-processwire Hopefully this makes things more clear. And here is a great resource for some basic docker commands (listing/removing of images, containers and volumes). I needed them a lot when experimenting... Please let me know how it is going for you.
    2 points
  11. ProcessWire Prism JS Syntax Highlighter A module to parse given HTML and syntax-highlight code elements using Prism JS Features Support for 120 languages Very lightweight, core weights 2KB minified gzipped. Customizable. Specify your own CSS, or use one of 8 default themes Hookable. Use hooks to specify your own custom CSS, and JS Plugin support. You can use all available plugins that come with Prism JS. Installation Add module to /site/modules/ and then install. Or go to Modules > Install > Add New and use any of the options provided to to install. Create a text/textarea field or use an existing one then pick Prism Code Highlighter from Details > Text Formatters. Protip: This module parses HTML markup, so it should come after HTML parsers such as Markdown textformatters. Add code elements within the field content with language-xxxx classes. Or pick a default language from configuration page if you are unable to specify the classes. Go to configuration page and select any plugins you want. To use some plugins, extra classes are required. See plugin documentation. Install these recommended modules for the best experience: Parsedown Extra module to render Markdown Extra into HTML. You can also set custom attributes for each element unlike vanilla Markdown. Customization Go to module configuration to specify: Auto inclusion of highlighters for parsed languages Default language for inline code elements or ones without language-xxxx classes. Ability to use minified/non-minified component and parser files Plugin options Theme options Custom JS and CSS for configuration / theming Ability to use hooks to specify custom CSS and JS Hooks Hook into TextformatterPrism::getCustomCss and TextformatterPrism::getCustomJs in your ready.php file and return an (array of) URLs as follows: // specify custom CSS wire()->addHookAfter('TextformatterPrism::getCustomCss', function (HookEvent $event) { $event->return = 'path/to/custom.css'; }); // Specify custom JS wire()->addHookAfter('TextformatterPrism::getCustomJs', function (HookEvent $event) { $event->return = ['path/to/custom.js', 'another/custom.js']; }); Screenshots Links https://github.com/abdusco/pw-prism-code-highlighter http://prismjs.com/ http://modules.processwire.com/modules/textformatter-prism/
    1 point
  12. Just to confirm that @TomasDev's answer does, indeed, work. Thanks, Tomas!
    1 point
  13. Cache....or staring at a screen for too long can do that to you sometimes .
    1 point
  14. @adrian, page save might result in emails being sent every time that page is edited. I suggest 'Pages:added' instead.
    1 point
  15. True At that time Tracy Debugger didn't show any errors @adrian. To check if it really had nothing to do with your module I uninstalled it (will install it again, no worries ) and tried to import the images again. Everything worked as expected again. It feels a bit unreal to me, as I tried many things and now it works on the code I wrote at the start of developing this feature.
    1 point
  16. @mr-fan Thank you for the code. The problem is my low experience and that the template I am using contains Angular. At this moment I can't redo the code Angular->php @kongondoThank you very much for your suggestion. I can assure you that I have been searching a lot within the forum and the modules without success. Obviously, I searched with the wrong key words. I also haven't found this, sorry. However, I have installed that module SchedulePages and seems to work very fine. Thanks a lot, it is what I needed, a simple way to switch on the pages automatically. Thanks again! !! Best wishes
    1 point
  17. Nothing jumps out at me. Things to confirm: $imgfield = $product_pages->images_product; Are you sure that returns an Object and not Null? Some other comments, by the ways... Is this by your design or by necessity (i.e. Prestashop demands that). Normally, especially in cases where several products can share one or more categories, you want to have categories separated from the products (i..e not as their children). // ensure output formatting is off $product_pages->of(false); This is not necessary here. Output formatting is always off in a module context. if (!$parent->hasChildren()) { } That may not be very foolproof (could children have been manually deleted?). You can check using the module version instead, i.e. if version is less than x, do this, else do that. I can't find the exact syntax for it now but will edit this post later if I do. Edit: grep version_compare under /wire/modules/ for more examples. Here's an example from a third-party module, changelog. Edit 2: Arrgh. Scrap that. That's not it really; Hopefully someone will chime in. You should be able to compare versions of your modules programmatically though; I'm sure of it.
    1 point
  18. ...for such things there is no need for a whole fieldtype since you can make it in plain PHP. Usecase that i have was to depublish entries after a fix timeperiod that a user could set to his entry (1 week, 3 weeks and so on) Just as an very simple example from a .php file for a cronjob: //get all items to check foreach ($items as $e) { /// FIRST STEP - send mail 1 week before the entry is being unpublished! //set the calculate_type to the e_delay option value from the entry option field... $calculate_type = $e->e_delay; //calculate the to add time to the timestamp switch ($calculate_type) { case '1': $time_add = ' +3 week'; break; case "2": $time_add = ' +7 week'; break; case '3': $time_add = ' +11 week'; break; default: $time_add = '1'; } //timestamp to check is the modified date + $time_add $check_time = strtotime($time_add, $e->modified); //check if the current timestamp is greater than the $check_time == 1 week before e_delay is reached! if ($check_time >= $curtime) { //do something } else { //do something else } } the time peroids that you need could be a simple option field or a pagefield or even an integer field. Best regards mr-fan
    1 point
  19. That is looking really nice - I agree, the default styles from the Tracy core are ugly as - really looking forward to your final version - thanks! BTW - nice seeing that you are making good use of the console Snippets While you're in the mode for tackling this stuff, if you feel like it, it would be incredible if you'd be willing to take a look at this: https://github.com/nette/tracy/pull/241 As it mentions, that PR is a work in progress, but it looks like it's going to do more harm than good in my opinion. From my initial experiments, it's going to make it very difficult to get the ACE editor styles into the Console panel. In particular, have a read of my comment here: https://github.com/nette/tracy/pull/241#issuecomment-273268211 - most importantly, note that I always hack the Tracy core's /tracy-master/src/Tracy/assets/Bar/bar.css to change line #23 from #tracy-debug * { to #tracy-debug-bar * { Perhaps we should talk about this more via PM if you are interested in helping to get everything working with that new approach that is in the works. PS - no pressure - I am sure you have lots of other things to do. I have been putting it off for the moment myself
    1 point
  20. Could you explain a use case for this? Other than that, not sure if you know that there's a module that can auto-publish/unpublish at specified dates. There's also a published date property for pages. I don't know if those cover your needs, but good to know.
    1 point
  21. Thanks - I wasn't aware of that system tab before. I'm sure Ryan must have had a reason for disabling the trashing of user pages by default but in testing so far it seems okay. I had to uncheck the "Don't allow pages to be moved" option for the user template too in order to allow trashed users to be restored.
    1 point
  22. https://github.com/processwire/processwire/pull/54
    1 point
  23. If you enable $config->advanced you can have a look at the system tab in each of your templates. There you can prevent pages of a template to be trashable. But I'd be cautious with enabling the trash for the user template as you might find issues with trashed users not behaving exactly like non-existing ones.
    1 point
  24. That was it THANKS. I got this as an error: Call $page->setOutputFormatting(false) before getting/setting values that will be modified and saved. Is that what the 'of' stands for in of(false) ? outputformatting? Call $page->setOutputFormatting(false) before getting/setting values that will be modified and saved.
    1 point
  25. Sounds like a good idea to me. @bernhard actually mentioned here as well many pages back, but I never got around to it. @bernhard - do you have the latest version of the code available somewhere?
    1 point
  26. I tried this module today to output a video preview from a multilanguage field. Worked like a charm. See the screenshot. I created two fields, one for the default language (English) and one for Portuguese. Here's the code for both, if someone's interested: English field: return '<iframe src="https://www.youtube.com/embed/'.$page->youtube_id.'/?showinfo=0&amp;iv_load_policy=3&amp;controls=1" frameborder="0" allowfullscreen width="100%"></iframe>'; Portuguese field: //1021 is the 'portuguese' language page id $youtube_id = $page->youtube_id->getLanguageValue(1021); return '<iframe src="https://www.youtube.com/embed/'.$youtube_id.'/?showinfo=0&amp;iv_load_policy=3&amp;controls=1" frameborder="0" allowfullscreen width="100%"></iframe>'; Thanks @kongondo for this great module!
    1 point
  27. 1 point
  28. New Captain Hook version just posted! Changes: I have rewritten the file parser so that it uses token_get_all, rather than a regex. This makes it much faster and it also makes it easier to exclude functions that are commented out. Please let me know if you notice any files/hookable methods that aren't listed. Added a new column which has the className::hookName formatted and ready to copy/paste. Hooks for site modules will be automatically added when a new module is installed. Cached version is now stored in the DB cache table, rather than on the filesystem.
    1 point
  29. New Captain Hook panel just added! Features: The hooks are parsed directly from the files in your PW installation, so they will always be up to date. They are cached, but will be updated whenever you upgrade your PW version. If you have your Editor Protocol Handler properly configured for Tracy, clicking on the Line Number will open to the method in your code editor. This panel uses @owzim's Captain Hook generator: https://github.com/owzim/PWCaptainHookCLI Please let me know if you have any problems or suggestions.
    1 point
  30. With the latest dev version, you can also now do: $urls->httpRoot
    1 point
  31. @gmclelland - I decided to go ahead with adding this anyway The latest version replaces the existing close (x) button with a hide arrow. This is what it looks like when hidden: In case anyone is wondering, this is quite different to the Enable/Disable button (either from the dedicated panel, or from the panel selector) because with this new option, even when hidden it is still capturing errors etc and when you unhide/show it will instantly show it's information without the need for a page reload. There is also a new module config setting to "Hide Debug Bar By Default". That should be self-explanatory, but keep in mind that once you have clicked on the show or hide buttons, cookies take over controlling its status. Please let me know if you have any problems. Just an FYI - I am not a big fan of this because you won't be alerted about non-fatal warnings/notices while the debug bar is hidden, but I think it's nice to give users the option if they prefer it.
    1 point
  32. Have a look at wireRenderFile, it does the output buffering stuff for you. $out .= wireRenderFile('./inc/training-item.inc', array('p' => $p));
    1 point
  33. To be honest I'm not sure this will make things considerably easier to grasp for (new) people. I can already see people trying to use it as replacement for a templating language. I really don't think it's worth it just to not have a $main/$sidebar variable, especially for new people. I'd imagine it's more confusing than helping. I'd much rather would like to see a guide dedicated to examples of direct output -> delayed output -> separation business logic / view logic -> templating engine (twig/blade), what the benefits are and how to switch between them (e.g. same output in different strategies). Especially the third one is a kinda pet peeve of mine, because I went into the rabbit hole myself, where markup was so deeply coupled with processwire api stuff, that it was a nightmare to change anything. For me this seems to be more in line with your motto of teaching people how to fish.
    1 point
  34. Sounds like you would want to handle 5 data types: boats rooms cruises customers bookings A boat I'm assuming has a fixed number of rooms. Perhaps start with a data model like this which takes everything into consideration: Boats (boats.php) Boat A (boat.php) Room 1 (room.php) Room 2 Room 3 ... Boat B Room 1 Room 2 ... Customers (customers.php) Customer 1 (customer.php) Customer 2 ... Bookings (bookings.php) Booking 1 (booking.php) Booking 2 ... Cruises (cruises.php) Cruise 1 (cruise.php) Cruise 2 ... Cruise template fields: title date boat (page-select to /boats/, boat.php) Customer template fields: first name last name (other typical fields) Cruise template fields: title boat (page-select to /boats/, boat.php) date Booking template fields: customer (page-select to /customers/, customer.php) cruise (page-select to /cruise/, cruise.php) rooms (based on cruise->boat, select for the rooms that the boat has) I'm assuming the interface would be PW's admin. Perhaps use some hooks and ListerPro to tie it all together. Make it as user-friendly as possible. Maybe have a page within the admin outputs each cruise with which rooms have been booked vs. unbooked which would be friendly to the site admins.
    1 point
  35. Hello, I fixed my problem. The solution was easier than its research Just needed to truncate cache table in MySQL.
    1 point
  36. I rather see a problem for users that might go to a page that doesn't exist. This is my biggest concern. Basically I don't mind having a longer URL-structure If you make it viewable later on, well, then it would be like rearranging your content structure. You're then adding a layer that helps user finding your content better. But if I decide that this layer isn't needed, then I see more sense in leaving this layer out of the URL structure. In the end, it's not the biggest issue, I just want to understand the basic idea behind it, so ist would be great to get some insights on that reasons you mentioned, as I still don't understand it
    1 point
×
×
  • Create New...