Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/01/2023 in all areas

  1. In a recent GitHub issue report, I was asked about output formatting in ProcessWire, and where more information could be found about it. I know I've written about it numerous times, and went to locate the documentation page, only to find we didn't have one! Output formatting is such an important topic, so here is everything you need to know. I hope you'll find it simple enough, but also useful and thorough— https://processwire.com/blog/posts/output-formatting/
    4 points
  2. Use something like this: <?php wireIncludeFile($page->type_menu); ?> What exactly do you have in the "type_menu" field? You have to make sure that only your desired files can be accessed/included! Perhaps it is also better to map this via a switch/case - perhaps an if is enough: <?php if($page->type_menu == "menu-A") { wireIncludeFile('styles/menu-A.php'); } else { wireIncludeFile('styles/menu-B.php'); } ?>
    2 points
  3. I think you have to do it like this: for ($i = 1; $i <= 40; $i++) { $fieldname = "field_$i"; if($page->$fieldname == 'test') { // do stuff } }
    2 points
  4. @ShadowByte first let me say welcome to the PW forums ? The module does work with repeaters, but perhaps not in the way you are expecting. If you are relatively new to PW you may not be aware that every repeater item is a page, and those repeater pages have their own template. Repeater template names take the form "repeater_[field name]" and to see them in the templates list you have to enable "Show system templates" in the Filters section. The Connect Page Fields readme says: The way you have configured the module you have connected the fields "Track lyric" and "Albums". But the Albums field allows pages using the album template, and the album template doesn't contain the lyric field. Instead the lyric field is used on the repeater template (if the repeater field is named "tracks" then the template will be "repeater_tracks"). So for Connect Page Fields to work you would need to have a Page Reference field that defines its selectable pages as those using the repeater_tracks template and then connect that field to the lyric field in the Connect Page Fields config. As a side note, it's redundant to double up the connections like this in the module config: The connections are two-way so you only need to link a Page Reference field to its partner once. Assuming you actually want to connect albums to lyrics and not repeater_tracks items to lyrics, and you want to still use Connect Page Fields to avoid writing your own API code to synchonise the Page Reference fields, here's how I would do it... 1. Create a new Page Reference field (multiple pages) named "track_lyrics" that allows pages with the lyric template. 2. Add this field to the album template. Later on you might set its visibility to "Hidden (not shown in editor)" but for now leave it visible so you can check that everything works as expected. 3. In the Connect Page Fields config, connect the albums field to the track_lyrics field. 4. Add a Pages::saveReady() hook to /site/ready.php that will populate the track_lyrics field with all the lyrics that have been selected inside the repeater items on the page, every time an album page is saved. It might look something like this (update the template/field names if needed): $pages->addHookAfter('saveReady', function(HookEvent $event) { /** @var Page $page */ $page = $event->arguments(0); // Album: populate the track_lyrics field from the "tracks" repeater items if($page->template == 'album') { $lyrics = new PageArray(); foreach($page->tracks as $track) { $lyrics->add($track->lyric); } $page->track_lyrics = $lyrics; } }); Hope this helps!
    2 points
  5. Hi! EDIT Sorry this is on v 4.25.5 Running a bardump on the front-end for a variable (in this case, I'm passing a latte_vars array for verification) throws a type error: That $object_or_class array is:
    1 point
  6. Thanks @gornycreative - I never use that Iterator tab on the dumps panel, but error should be fixed in the latest version.
    1 point
  7. Nevermind. Fixed. My problem was an extra field presented in the basic-page-edit.php
    1 point
  8. In the regular site profile you can find the function that controls this output in the file called '_uikit.php' in the templates folder. Find the function 'ukBlogPost()' and go to the line defining the variable '$date' (see here on Github) to change it. Currently it is looking for the date (modified) and falling back to the created date string 'date|createdStr' -- just remove the 'date|' bit and leave 'createdStr'. Be sure to check the other functions in that file for other places the date may be displayed.
    1 point
  9. Progress is going on well, as usual my choice for Development: TemplateEngineFactory + Twig {% for article in articles %} {% set divisor = 10 %} {% if loop.index0 == 0 %} <div class="flex-center flex-col aa-list"> <h4>Articles</h4> <ul> {% else %} <li> <a href="{{ article.url }}" target="_blank" >{{ article.title }}</a > <span> {{ article.publishedStr }}</span> </li> {% endif %} {% if loop.index % (divisor + 1) == 0 %} </ul> </div> <div class="flex-center flex-col aa-list"> <h4>Articles</h4> <ul> {% elseif loop.last %} </ul> </div> {% endif %} {% endfor %}
    1 point
  10. I didn't want to create a topic for this, so I decided to use my existing thread , as mentioned, I am creating some Youtube tutorials around Processwire, I feel a video is much more easier to help people getting started with Processwire. So I did a first video introduction, However I quickly realized my dilemma with self expression skills when talking, so I am working on that but here is the first video and I hope to drop a Video per week or more depending on how fast I can get things out but I am also open to covering other complex topics too around Processwire. Thanks and I hope this helps out a lot of people. NOTE: LOL Working on how I sound too ?, bear with me Love from Nigeria
    1 point
  11. I had the same problem, hope this will help someone. :) I have a multi language website with templates containing a page field called Tags, that the user can create on the fly. Here's a quick way to activate the secondary languages when a new tag is created, using the cool IftRunner module. Install the module https://github.com/ryancramerdesign/IftRunner Create a .module name inside /site/modules/IftRunner using the code below. Install this module "IftActionActivePageLanguages" you just created Go to Setup > Trigger/Action inside the admin dashboard Create a new trigger for a "Pages::saved" hook like the one shown in the screenshot.
    1 point
×
×
  • Create New...