Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/27/2022 in all areas

  1. I use the tools that ProcessWire comes with. I spent a lot of time making them simple and easy to use, and that's what I like to use. Just as an example, let's say that I've got a website and a client wants to add a full featured blog to it. I'll develop it on my local copy of the site and it might involve creating several fields, templates and template files. I'll take a day or two to develop it and when it comes time to migrate the finished work to the live server, that's the fun part, but there's not much to it: Create or export/import the new fields on the live site first, then do the same for the new templates. Copy the new or updated template files (and related CSS/JS assets) into place. Create or export/import the pages needed by the blog, and it's done. A blog is just an example but it's the same as any other update. It's a painless process that always goes quickly and smoothly. This part of it takes maybe 5 to 10 minutes and is one of my favorite parts of the project, like driving a new car and then seeing it for the first time in your driveway. I like to oversee this part of any project and have no need to optimize it further so guess I'm not the target market for add on migration tools. That's correct, it would be fairly straightforward.
    5 points
  2. Since these tags are introduced by CKEditor you know they’ll always be there and always look the same (I guess). So you can pretty much just count how many characters you want to skip at the beginning (3) and end (4) and do it without ever mentioning anything about <p> and </p> to PHP: $bodyCopy = mb_substr($pages->get("/nastavitve/")->kontaktni_podatki, 3, -4); Or you can go the replace route: $bodyCopy = mb_ereg_replace('^<p>|</p>$', '', $pages->get("/nastavitve/")->kontaktni_podatki); Note how using mb_ereg_replace you don’t need those annoying slashes. The regex ^<p>|</p>$ just means, “find a <p> at the beginning OR a </p> at the end”, so this leaves all the inner p-tags alone. You can get more fancy if you need to take into account all the ways a HTML tag might appear, but eventually you’ll get into this territory. There is also the ol’ strip_tags function and ProcessWire ships with a Textformatter module called ParagraphStripper, I believe. As well as HTMLPurifier if you really want to get your hands dirty.
    3 points
  3. Hi @fruid Try to validate your page with https://validator.w3.org/. Gideon
    2 points
  4. hi, honestly, hard to answer without seeing the whole page source code but you can bet that when this kind of thing happens you have somewhere either an unclosed tag (hence the whole page source code) or, and it happens more often than you could imagine, something like two body tags ("like" because it happens with a few other important tags too) just an example of when this kind of thing happens, using markupregions and forgetting an html head in another template than the _main.php => two html head and opening bodies => a little mess ? hope it may help looking for the issue origin have a nice day
    2 points
  5. Okay so I resolved this by chance - it won't work in PageAutocomplete UNLESS you give it a "normal" field as an alternative, so here is what you need in the config for that field in the table: labelField=myFooLabel|title I suspect what is happening is the AJAX request doesn't know what myFooLabel is for some part of the request but this makes the items appear in the list using myFooLabel which was a nice surprise! Not really sure why it makes it work, just guessing above but it does work and that's the main thing ?
    2 points
  6. I agree that the drag cursor isn't needed here. I don't like the idea that any click on the image would delete it, but what I've done in v0.2.0 is that when the max items is set to one and an image is already selected in the inputfield then the button is labelled "Replace image..." so that the next selected image will replace the existing image with a minimum of clicks.
    2 points
  7. This is the thread for the old version of RockMigrations wich is deprecated now and has been renamed to RockMigrations1 Here is the latest version of RockMigrations: -- Old post from 2019 -- https://github.com/baumrock/RockMigrations1 Quickstart First make sure you have backups of your database!! Install RockMigrations Create this ready.php <?php /** @var RockMigrations1 $rm */ $rm = $this->wire('modules')->get('RockMigrations1'); $rm->migrate([ 'fields' => [ 'myfield' => ['type' => 'text'], ], 'templates' => [ 'mytemplate' => [], ], ]); Open your PW Backend and you'll see the new field and new template! Now add the new field to the template: <?php /** @var RockMigrations1 $rm */ $rm = $this->wire('modules')->get('RockMigrations1'); $rm->migrate([ 'fields' => [ 'myfield' => ['type' => 'text'], ], 'templates' => [ 'mytemplate' => [ 'fields' => [ 'title', 'myfield', ], ], ], ]); Reload your backend and inspect the template: Now let's add a label for our new field and make title+myfield 50% width: <?php /** @var RockMigrations1 $rm */ $rm = $this->wire('modules')->get('RockMigrations1'); $rm->migrate([ 'fields' => [ 'myfield' => [ 'type' => 'text', 'label' => 'My Field Label', ], ], 'templates' => [ 'mytemplate' => [ 'fields' => [ 'title' => ['columnWidth' => 50], 'myfield' => ['columnWidth' => 50], ], ], ], ]); That's all the magic! You can easily lookup all necessary properties in Tracy Debugger: Let us add a Textformatter as an example! Add the textformatter via the PW backend (not via RM), save the field and inspect via Tracy: Now add this data to your migration: <?php /** @var RockMigrations1 $rm */ $rm = $this->wire('modules')->get('RockMigrations1'); $rm->migrate([ 'fields' => [ 'myfield' => [ 'type' => 'text', 'label' => 'My Field Label', 'textformatters' => [ 'TextformatterEntities', ], ], ], 'templates' => [ 'mytemplate' => [ 'fields' => [ 'title' => ['columnWidth' => 50], 'myfield' => ['columnWidth' => 50], ], ], ], ]); Ok maybe you noticed that migrations are now running on every request which may slow down your site a lot! RM2 will have a feature to automatically detect changes and fire migrations automatically. RM1 does not have this feature, but I've used a technique in all my projects that fires migrations on every modules refresh. Simply wrap the migration in a fireOnRefresh method call: <?php /** @var RockMigrations1 $rm */ $rm = $this->wire('modules')->get('RockMigrations1'); $rm->fireOnRefresh(function() use($rm) { $rm->migrate([ 'fields' => [ 'myfield' => [ 'type' => 'text', 'label' => 'My Field Label', 'textformatters' => [ 'TextformatterEntities', ], ], ], 'templates' => [ 'mytemplate' => [ 'fields' => [ 'title' => ['columnWidth' => 50], 'myfield' => ['columnWidth' => 50], ], ], ], ]); }); How to remove things you created before you may ask? Use the declarative syntax: <?php /** @var RockMigrations1 $rm */ $rm = $this->wire('modules')->get('RockMigrations1'); $rm->fireOnRefresh(function() use($rm) { $rm->deleteField('myfield'); $rm->deleteTemplate('mytemplate'); }); Refresh your backend and everything is as it was before! PS: Make sure you have proper Intellisense support in your IDE to get instant help:
    1 point
  8. Sure... I know your workflow... yet... whenever I try it... it's like some illegal firework blew right into my face and my weekend was ruined. It's probably me in some kind or another. It's a workflow that doesn't fit into mine for some kind or another for whatever reason. Maybe I'm too old for those things or maybe I worked way too long with exports that mirrored all changes far too perfect from one system to another. (INXIRE CMS on Oracle - in case you want to know). But SURE I will look into this more but on the other hand the CraftCMS and CSV/JSON-Recorder I saw was almost perfect for my cases.
    1 point
  9. If I get some time I would love to work on building a module that would deliver a Craft CMS style solution for this, since I think that would work best for our projects. Just not sure whether I’ll get that chance or not.
    1 point
  10. Sounds good, happy to integrate that if you submit a pull request on the GitHub repo.
    1 point
  11. well if you want a dynamic code depending on an entry, yes you will ? your hanna code tag could accept either [[count_years]] or [[count_year startyear="1920"]] in this case you can just start your hannacode with a default value $start = $startyear != '' ? $startyear : 1980; this way you cover both insertion, with and without attribute and my pleasure ? have a nice day
    1 point
  12. Hi, the issue is not an Hannacode one but a simple php one try $start = 1890; // your attribute no need of strtotime $thisyear = date('Y'); $diff = $thisyear - $start; echo $diff; it should work have a nice day
    1 point
  13. Aha, I managed to get this to happen again. Step 1: delete two PageAutoComplete entries and save the page - the empty rows remain (I really wish empty rows wouldn't get saved but that's another story): Step 2: Typing into the fields in the two existing empty rows you can enter the same value twice (so below I just entered the Parkland Resort extra into the first of the two empty rows, and am able to add it again in the second of the empty rows) It respects the once-per-table setting when you add a new row, but not for empty existing rows. I do wonder if another belt-and-braces solution here is to simply check for and delete duplicate rows on save too?
    1 point
  14. Thx for the feedback. I guess many who are having your painpoint are missing RockMigrations because of this reason... I've updated the first post of RockMigrations with an easy step-by-step guide:
    1 point
  15. Yes, that did the trick. Was looking everywhere for something like this. Thank you a million ? R
    1 point
  16. I can't reproduce that. The column configuration I used for testing: Screencast: Is pagination turned on for your Table field by any chance? Can you provide steps for a basic test case where the problem occurs?
    1 point
  17. I looked into it a while back but wasn't sure how to use it. I think I need a little tutorial that walks though a particular use case.
    1 point
  18. The regex solution you mention only strips paragraphs containing a single non-breaking space, aka. &nbsp; aka. &#x00A0;. Do you really only want to remove the surrounding <p> tags? It’s likely to become a mess if you have more than one paragraph. To get rid of all <p>s a bog-standard str_replace should do the trick, I imagine. Unless there are arbitrary attributes on it, for example.
    1 point
  19. Hiya, loving this dashboard for a few more complex projects. I have a request for the number panel - since I often add a link in the "detail", if the number is zero then the link isn't shown. It would be great if there was a way to show it regardless. Actually it's hard to tell if it's a bug or intentional. In DashboardPanelNumber.module if I wrap the number in is_numeric it works when zero is passed as the number as below: public function setup() { parent::setup(); $this->locale = $this->data['locale'] ?? setlocale(LC_ALL, 0); $this->detail = $this->data['detail'] ?? ''; $this->number = is_numeric($this->data['number']) ? $this->data['number'] : null; if (is_int($this->number) || is_float($this->number)) { $this->number = $this->formatNumber($this->number); } }
    1 point
  20. OK, I found the problem. OPCache was enabled in the new version of MAMP Pro. Just turned it off and everything refreshes as it should. Hope that helps someone!
    1 point
  21. Another hidden treasure in the PW Backend: PW 3.0.61 introduced the VEX library for dialogs: https://processwire.com/blog/posts/processwire-3.0.61-master/#admin-and-ui This is how you can use them in your custom admin pages: In your module's php load the vex library (eg in the ready() method of your module - init() might not work as it might load too early!) $this->wire('modules')->get('JqueryUI')->use('vex'); Then in your javascript: // show confirm dialog ProcessWire.confirm('Are you sure you want to delete this E-Mail?', function() { // on confirm $i.removeClass('fa-trash').addClass('fa-spin fa-spinner'); $.get('./trash/?mailid=' + $a.data('mailid'), function() { $a.closest('.RockGridWrapper').find('.rockgridbutton.refresh').click(); }); }, function() { // on abort grid.api().deselectAll(); }); Result: I opened a pull request with a little fix for handling clicks on the CANCEL button. If you want to support it, give it a thumb: https://github.com/processwire/processwire/pull/108
    1 point
×
×
  • Create New...