Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/25/2021 in all areas

  1. Quick update... Finally figured out to get React/NextJS to work with a basic (minimal field types to convert to JSON) PW site. Giving self a pat on the back when I discovered Svelte ? Svelte felt (I'm a poet & didn't know it ?) so much more like PW - JS, HTML & CSS with 'state management' and no shadow DOM. The only problem was routing. I'd spent far too long figuring out React/NextJS routing and Svelte offered no immediate solution. The old (like 2yrs) way of routing was called Sapper. Development on Sapper has ceased with all efforts now focussed on the new way, SvelteKit which is in pre-beta (? ). Anyhoo, went with SvelteKit and got it working. I've only scratched the surface on what's possible with React/NextJS and Svelte. Both offer Server Side Rendering (SSR) making the site SEO friendly & fast-loading. Given a choice, I'd choose Svelte every time. With both React/NextJS and Svelte using @Sebi's AppApi with customisation depending on the framework, I: created a home page that pulls the data from the PW home page created a 'slug' page that pulls the data from the PW page url and displays it in a component based on the PW page template as returned in the page JSON, and shows the correct route in the URL from a nav menu In both cases, the page layout is not a PW template but a conditional component file. Anyone else tried Svelte with PW? Your thoughts & comments welcome
    3 points
  2. @Falk $string = '<figure class="align_right"><img alt="some random alt text" src="path/to/image-file" /> <figcaption>some random caption text</figcaption> </figure> <p>some random text</p>'; $purifier = $sanitizer->purifier(); $purifier->set('HTML.ForbiddenElements', array('figure')); $purifier->set('Core.HiddenElements', array('figure' => true)); $clean = $purifier->purify($string); $text = $sanitizer->truncate($clean, [ 'type' => 'sentence', 'maxLength' => 400, 'visible' => true ]); $content = "<p>"; $content .= $text; $content .= "</p>"; d($content);
    3 points
  3. Hi @matjazp, Thank you for your help, I'm not sure I would have tracked this down without that last suggestion to comment our the hidden visibility. Long story short it was my own fault! I built this site a long time ago and, in my naivety back then, added a protection line at the beginning of the main admin.php template that redirected front end users if they were to ever stumble on a real admin page using Fredi (the previous FE editor I was using). That line was redirecting front end users as soon as FEEL was trying to open an admin page. Oddly that wasn't happening with Fredi!?! Anyway, it's now working as expected and it was my fault not the module! Thanks again!
    1 point
  4. On the DETAILS tab, at the botton marked: Markup/HTML Options(Content Type) (Your Content Type in the setting above has to be Markup/HTML)
    1 point
  5. aaand... not to forget, in the CKE field you can set: Update image alt attributes (Replace blank alt attribute with image description) If an image description is set, it will be used automatically.
    1 point
  6. I think you must have something else going on that's causing the problem, because using a page ID does work in PW v3 and it's included as an example in the documentation. // Get a page by ID $p = $pages->get(1234);
    1 point
  7. You found the solution just 4 years after posting this thread?! Wow. That's fast ?
    1 point
  8. Hi @benbyf If you right click on the image in the CKEditor field and select "Image Properties" then click on the quote marks icon you can edit Img Alt there.
    1 point
  9. Horses for courses, I think @opalepatrick. PW is undoubtedly an excellent tool for admin-type applications. I have done a couple (a membership system with an integrated public website and a holiday cottage booking system which is loosely-coupled to a public website) and have found that it works well. However, you do need to think about the design quite carefully if you want it to perform elegantly and be maintainable. So far I haven't found any really good tutorials on this topic. The systems I have built tend to have the following characteristics: Use PW's page-based structure as far as possible for the database and straightforward edits; Use existing modules that suit the purpose to avoid re-inventing the wheel - I find ConnectPageFields and RuntimeMarkup/RuntimeOnly particularly useful; Use process modules for custom user interfaces - typically using MarkupAdminDataTable; Use the access control tools as required - I also use the RestrictTabView module; Use Listerpro for ad-hoc reporting; Tweak the interface as necessary with js. Inevitably you will take some wrong turnings, but PW is a great prototyping tool and genrally not too much time is wasted (certainly not compared with doing the design wrong in pure php). And the forum is great too, if your brain starts to hurt, as mine seems to frequently ?
    1 point
  10. @BillH Meanwhile the hook is working. All data is collected in one textarea that I’ve set to hidden. It still is a workaround in the sense of not going the direct way, but it does what I wanted to achieve without any noise or bad smell, so I would call it an excellent solution. Means: my efforts on searching for something different declined dramatically. Here is the complete hook – less for you as the "inventor", but for others that may get stuck at the same point. I keep the code in /site/templates/admin.php as it is admin related only, but /site/ready.php would work as well. <?php $wire->addHookAfter("Pages::saveReady", function($event) { $page = $event->arguments(0); $page->of(FALSE); // disable page formatting $cache = ""; // string collecting the single fragments if ($page->template == "invoice" || $page->template == "standard") { // blocks is a Repeater Matrix field with the types item and text foreach($page->blocks as $block) { if ($block->type == "item") { $cache .= $block->title." "; $cache .= $block->body." "; } else if ($block->type == "text") { $cache .= $block->body." "; } } // notes is a direct child of $page $cache .= $page->notes." "; } else if ($page->template == "customer") { // cust_base is of (pro) field type Combo, it stores data different // from Repeater Matrix fields but shares a similar syntax $cache .= $page->cust_base->street." "; $cache .= $page->cust_base->city." "; $cache .= $page->cust_base->shorthand." "; $cache .= $page->cust_base->phone." "; $cache .= $page->cust_base->email." "; $cache .= $page->notes." "; } else if ($page->template == "contact") { // cust_contact is a Combo field too $cache .= $page->cust_contact->prename." "; $cache .= $page->cust_contact->surname." "; $cache .= $page->cust_contact->phone." "; $cache .= $page->cust_contact->email." "; $cache .= $page->notes." "; } // searchcache is a simple Textarea field that can be included // as a searchable source in Modules/Core/ProcessPageSearch $page->searchcache = $cache; }); ?>
    1 point
  11. Hey! This is a very early/experimental/alpha not for production environments release of a new module I'm working on. Just testing the possibilities and the interest that might be for such a thing. The idea is to be able to quickly create fields while working inside the template files without having to go to the admin. For example, in an early stage of development when creating a layout, insteading of putting a placeholder headline and then going to the admin to create the headline field where the real content will be, you can create the field directly from the template file by doing: <h2><?=$page->field("A nice headline", "headline", "text")?></h2> This will create a new "headline" text field when it doesn't exist in the system and add it to the the template of the page you're working on and add "A nice headline" value to it. On a second run the module will recognize that the field already exists on that template and will simply return it's value. The method accepts three string parameters in the order ( value, field name, field type ). Value and name are required but field type will assume "text" when omitted. $page->field("A nice headline", "headline"); // creates a text field $page->field("A nice paragraph", "body", "textarea"); // creates a textarea field The method also accepts a boolean parameter in any position: TRUE forces the value to be saved into the field on that page, FALSE (or omitted) sets that value to the field when it adds it to the template, but leaves it how it is when the field already exists in the page. This is the only situation when this module can be destructive, and it's only concerning the value of the field on that page: $page->field("Another nice headline", "headline", TRUE); // will create or add a text field and add the value to the page even if the field already exists there The method also accepts an array as parameter. This array will be used as options for the creation of the field. The options array will override the string parameters when they clash. $page->field("A nice headline", "headline", array( 'name' => 'subtitle', 'label' => 'Subtitle' )); // will ignore the name "headline" and use "subtitle" instead As soon as the fields are created and added to the template, all the method will do is return the value, just like if using $page->headline, unless you use the TRUE parameter which will override the value of the field by the value in the first parameter. -- With this module you can, for instance, convert an existing HTML template quickly, just by pasting the html into a template with no fields created yet, and going through all the code, replacing the content by calls to my field() method. In the end you should have a working page with all the fields created in the template. Now you just need to go to the fields and adjust their preferences. So, just download it > install it > test it > tell me what you think! dynamicPageFields.module.zip -- Edit: Multilanguage fields threw an error but they don't now. You can create a multi lang text by doing: $page->field("A nice headline", "headline", "textlanguage"); that third parameter is just a case insensitive simplification of input field names to make it easier to write. You can still use the original input field name like "FieldtypeTextLanguage" if you prefer.
    1 point
  12. I just migrated three of my projects from MODx Evolution to Processwire. The sites itself are not that spectacular but I am a little bit proud that writing a migration script with PW is so damn easy! So I just wanted to share some thoughts how I realized it. Since the projects are very small and have only a few templates and fields it was very easy to set up templates and fields for these three in the PW admin interface (btw: I really like the possibility to export and import fields via the admin!). Template files were more or less a simple copy paste from the MODx backend to the PW templates files. After transforming the MODx placeholders and all that MODx related stuff in "PW language" and after setting up all fields I imported the MODx database tables into my PW database. From this point the migration script started it's work: Step 1: Map existing MODx templates to my newly created PW templates Step 2: Map all necessary fields from MODx to PW fields (based on the previously selected templates) - or just ignore fields I don't wan't to migrate Step 3: List all existing pages and select the pages that should not be migrated (e.g. old sitemap page). From this point on my migrator script did all the work. It created all pages (including the site structure with all its parents and children) and their fields. After importing I just had to copy the content from the old homepage (which was created as a seperate page below the root page) to the root page. That's it. Moving projects took about 1 hour. The most extensiv part in this process was to transform MODx templates to PW, build a new contact form and a menu function. All my projects were without users and permissions so it was quite low easy. At the moment I am working on the migration of a more complex website. This will take much longer but since the PW API is totally easy to understand it's not that hard at all. So thank you all for this great support and this framework! I really appreciate it! Long story short: Here are ex-MODx websites proudly powered by Processwire My own website with some stuff about me: http://brlnr.de And two more sites about events around sailing in Berlin http://www.ansegeln-berlin.de/ http://www.absegeln-berlin.de/
    1 point
×
×
  • Create New...