Jump to content

TomPich

Members
  • Posts

    49
  • Joined

  • Last visited

Everything posted by TomPich

  1. Hi webguy, Unless your client wants to be able to entre their Google Tag ID themselves, no need to create a field for that. As markus-th said, just hard-code it in a partial template that is included on every page (the one that contains the <head> part of your pages).
  2. Thanks a lot! I’ll try your solution, Ryan. I didn’t think about caching a prerendered html string, but it seems perfectly logic 😊
  3. Hey howdytom, I’m not sure I fully got your need, but for what I understood (i.e. use the same image in multiple places), I would create a page called media, and add a multiple images field – with maybe a specific text field added to each image, called for instance "role". I would put all the images I use repeatedly here. I can then call these images anywhere on the front (and in TinyMCE). The role field would allow me to easily filter the images I need.
  4. Hello guys, I’d like to dig a little bit in the $cache API. In my homepage template, I call data from on other page, in repeater field. Although it has only 16 items, I noticed that it slowed down the loading process. When I use the cache a template level, the page is definitely faster. In the homepage template, I do the following : $consultants = $pages->get(1027)->repeaterConsultants; foreach ($consultants as $consultant) { // do stuff with $consultant->consultantPortrait, $consultant->consultantName, etc... } I tried to put in cache the $consultants variable. I read a tutorial on processwire.dev and I read the docs but I can’t get it working... The test below work perfectly though. $test = $cache->get("test", 3600, function(){return "this is a test";}); var_dump($test); So how could I cache the $consultants variable? Thanks.
  5. Thank you very much, Bernhard. This DefaultPage class will be very handy for a lot of stuff !
  6. Hello all, For my current project, each page have an image called thumbnail used for various purposes. If the thumbnail is not provided, I have a fallback image. So on almost each PHP template, I have the following code at the beginning: $thumbnailUrl = $page->pageThumbnail ? $page->pageThumbnail->size(1920, 400, ["crop" => "center"])->webp->url : $pages->get(1039)->configDefaultImage->url ; To avoid repeating that on each page PHP template, what can I do to generate, for each page, something like $page->thumbnailUrl automatically? Do I have to use a hook ? Thanks guys for your help Cheers Thomas
  7. I received so much help from kind people on this forum; it’s now my turn to contribute. 😊 I recently had a need for a customer. They have a long list of articles, and they wanted to find any article corresponding to some criteria. They could use the Pages > find tool, which use pageLister, but then they would have to each time select some filters, which can be quite intimidating when you have many fields. So my idea was to create an admin page with the right filters already set. The customer only needs to use some of them. As I found out, this is much simpler than I first thought. So my tutorial is not rocket science, but my hope is that it helps newbies like me to achieve this... 😊 So first, you need to create a simple custom admin page. Bernhard already made a nice tutorial about this, and it’s quite straightforward (like everything in PW ❤️). Here is the code to create this custom admin page in our situation (thanks to Bernhard) : namespace ProcessWire; class ProcessArticlesList extends Process { // Infos about your module and some settings public static function getModuleinfo() { return [ 'title' => 'Articles Admin Page', 'summary' => 'No need to be afraid of building custom admin pages. ;-)', 'author' => 'Your name goes here', 'version' => 1, // you can set permissions here 'permission' => 'meeting-view', 'permissions' => [ 'meeting-view' => 'View Meetings page', ], // page that you want created to execute this module 'page' => [ // your page will be online at /processwire/articles/ 'name' => 'articles', // page title for this admin-page 'title' => 'Articles', ], ]; } public function ___execute() { // the logic goes here } } So, with this code, you get a new module that will produce a blank page. You have now to create a ProcessArticlesList folder inside that file in the site/modules folder and put your new file inside. Then, activate your module. The ___execute() method will run on page load. It’s supposed to return a string which will be your page content. Now things get quite... simple! 😄 The idea is to run an instance of ProcessPageLister, with custom parameters. You can find all these parameters in /wire/modules/Process/ProcessPageLister/ProcessPageLister.module (there are comments that really help you) and you can also have a look at the API doc about ProcessPageLister. Here is an example that covered my needs : public function ___execute() { // this is to avoid error detection in your IDE /** @var \ProcessPageLister $lister */ // get the module, so that you can use it the way you want. $lister = $this->modules->get("ProcessPageLister"); // from here, the comments in the source file were self explanatory, so I found how to cover my needs // filter all pages with the "meeting" template. This filter is by default, won’t show // in the filter list and cannot be changed. $lister->set('initSelector', "template=meeting"); // Then I set 3 filters, left blank, so that the user has just to fill them – or leave them blank $lister->set('defaultSelector', "title%=, themes.title%=, text%="); // Disallow bookmark creation. In my use case, there was no sense for that. $lister->set('allowBookmarks', false); // let the table be full width $lister->set('responsiveTable', false); // use the custom order defined by the user by moving the pages in the page tree $lister->set('defaultSort', 'sort'); // and just show the configured filter on the page. return $lister->execute(); } As you can see, there are 7 lines of specific code to achieve that. How elegant! 🥰 Hope that it is helpful to someone somehow. Cheers Thomas
  8. Hi folks, When you use page lister and select filters, is there a way to specify a OR for some filters? Something like "Title contains text like my_word" OR "Body contains text like my_word"? I’m pretty sure I saw a checkbox to specify some OR conditions recently (I think it was in the BatchChildEditor), but I can’t find it any more. Couldn’t find any clue on the forum. Thank you guys for enlighting me. Cheers
  9. For me, whether I select this option or not, it doesn’t work. Not a big deal though. I just wanted to know if I got this functionality wrong.
  10. Hi folks, My research about hiding pages in the page tree led me to this thread. In the ProcessPageList module, there is a "Hide these pages in page list(s)" section where you can "select one or more pages that you do not want to appear in page list(s)." However, when I select a page, it’s still visible in the page tree. Is it normal? In which situation these pages would be hidden? I don’t get that. As always, thanks a lot.
  11. That’s great @adrian ! I had 1.8.25. The new one does exactly what I needed ! 😊
  12. Hey there, I’ve been playing around with BCE. I love all its functionalities and will need it for a project very soon. A quick question though : when in lister mode, you can define filters, and that’s great. But I could not find how to predefine blank filter. Imagine that my client will frequently use a filter on a field called "place". How can I get this filter ready to be filled, like "Place" + "contains texte like" + _blank_ ? Otherwise, he will always have to pick the right field and the right matching condition each time he lands on the page. And BTW, is there any way to hide the filter "Parents" "equals" "id" ? Because this is implicit and my cause confusion to my client. Many thanks in advance 😊
  13. @d'Hinnisdaël Thank you. I’ll explore your suggestions. I’m not sure what you mean by "configuring a separate admin Lister page with filters". But it sounds like being quite straight forward. For now, I’ve been building a custom panel following your documentation. Seems a lot of work. I’m getting somewhere, but I’d rather respect the spirit of your module and and choose a more clever solution to achieve my goal.
  14. Hey there, Still playing around with this awesome module. One question : is there a way to collect user input to customize the display of a collection? Here is an example. I have a template called “meeting” with 200 instances. I’d like to create a collection panel on the Dashboard, where the user can filter the result according to some simple entries fields : place (a simple text input) and themes (a multiple pages input). The way I see things : if the user does not filter, we have a paginated list of all the meeting pages (so up to this point, I did it). Somewhere in the panel wrapper, I have a text input where the user can specify a place. And another input (like select) where the user can choose a theme. Once done, the collection is filtered accordingly. Does dashboard have a way to do that (I didn’t find) ? Or do I need to create a custom admin page? Thank you guys!
  15. So, @da², @MarkE, @gornycreative, thanks to you guys, I am able to do what I aimed for. Once again, I’m baffled with ProcessWire API smartness and simplicity. Thanks you again, guys.
  16. Thanks @d'Hinnisdaël. I was editing my post because I found the solution. The value is stored as an actual date field type. As I need to get the date in french, using IntlDateFormatter, I have to store them as timestamp (I don’t want to install the whole traduction pack just for twelve months... 😅). See the --- edit--- part of my last post.
  17. Hey there! A quick, and, I’m sure, simple question about the Dashboard. I have a panel / collection. I want to display a date which is stored as timestamp (so I can display it properly in french in the front, with IntlDateFormatter). I can’t figure out how to format this timestamp date in the dashboard : $panels->add([ 'panel' => 'collection', 'title' => 'Meetings', "size" => "full", 'data' => [ 'collection' => 'template=meeting, limit=10', "dateFormat" => "d-m-Y", "columns" => [ "title" => "Meeting", "date" => "Date", ], 'sortable' => true, ], ]); }); The "dateFormat" option doesn’t do anything, I just get the timestamp. Any clue? Thank you 😊 ––– Found it ––– In the DashboardPanelCollection.module file, line 170, I found that : // Special case: timestamp fields // disabled for now (formatted datetime values work just as well) elseif (false && $fieldtype == 'FieldtypeDatetime') { $content = $this->datetime->date($this->dateFormat, $page->getUnformatted($markup)); } I got rid of the "false &&" and it works perfectly. So just my two cents : formatted values don’t work just as well : in my case, due to french language, I have to format the DateTime value from timestamp for the front site. And I don’t really care in the admin, but timestamp is a no go. 😊
  18. Waouh, thank you so much for detailing the steps. I have some food for thoughts. I’ll try to get my way into this.
  19. Thank you @da² So the actual role of the module would just be to handle the practitioner pages in a more convenient way than standard pages (like showing each page data in a line of a table) using PW API. Sounds interesting, and not too complicated. I will dig deeper in that direction in the coming days.
  20. Hello to all, So I just finished my third website with PW and I love it more and more. These were very simple sites, though. I would like now to explore deeper how to create modules for specific tasks, and I need some guidelines from you guys, as I don’t really know where to start from. Let take this case : I had, a few months ago, to do a website that has a public list of physiotherapists. Each member has some basic data. The client must be able to update the data from the admin side and add a picture. On the front, there is a main page with a list of all practitioners and each practitioner has their own page. All the initial data were exported from their previous Joomla website in a CSV file + picture for each member. I know how to import a CSV file content in a PHP array, and how to import the CSV data in a specific table in the database, so I can go either way. I was able to implement all that on WordPress (but I decided to quit WP). My goals – learn how to : import these data in PW in an automated way. make a specific admin page that allow CRUD operation on these practitioners. easily export this list when needed, in a convenient format (CSV would be the best). I guess this use case must be fairly common (importing existing data and managing them from PW admin). My questions : What would be, according to you, the best way to go : use a dedicated table in PW database (option A), or create a page for each practitioner (total of 50-100 practitioners) (option B) ? The last option sounds like making data export more complicated, but would benefit from PW native functionalities. Which docs / posts / tutorials would you recommand for a starting point ? I saw some stuff, but I still feel confused where to start from. In the meantime, I will start with ProcessHello module from Ryan. Thank you guys, for your time and your help. Even short answers would be greatly appreciated. 😊
  21. That’s absolutely great! Exactly what I needed.
  22. Thanks for your answer. I just noticed that sometimes it works, sometimes not. I’ll have a deeper look at this.
  23. Hello all, I have a tinyMCE field and a multiple images field in the same page. I would like to add a link to an image inserted in the tinyMCE field, something like : <a href="xxx"><img src="xxx"></a> I can’t achieve that : when I add a link to the image (after selecting the image in TinyMCE), the link appears inside <img></img> tags (wtf ?) and then it’s getting cleaned on submit. Linking some text works perfectly, though. Is it a bug, or am I doing something wrong ? Thanks in advance!
  24. Thanks Brendon. Happy to know that I’m not blind. I will give a thanks trophy anyway. People in this forum are so friendly, if I can boost their ego, it will be my pleasure... 😄
×
×
  • Create New...