Jump to content

kaz

Members
  • Posts

    230
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling
  • Location
    Munsterland

Recent Profile Visitors

1,625 profile views

kaz's Achievements

Sr. Member

Sr. Member (5/6)

34

Reputation

  1. @bernhard Thanks that works great. And also thanks for the training. I am quietly learning from a book by Christian Wenz and Tobias Hauser, but some parts only become clear when I use :)
  2. I have an address in the global settings which is displayed on all pages in the sidebar. <?php if ($global->businesshours): ?> <?php include('businesshours.php'); ?> <?php endif; ?> The client asked me to hide the address on only one page, id 1127. I can have an element displayed on a single site via a query, if ($page->id == 1042 ), but can I also exclude a page in an include?
  3. @TomPich If it can't be changed, it should be fine.
  4. I need to implement double quotation marks with a line break in an if query. my current code: <script type='application/ld+json'> { '@context': 'https://schema.org', 'sameAs' : [ <?php if ($global->facebook): ?><?= $global->facebook; ?>,<?php endif; ?> <?php if ($global->instagram): ?><?= $global->instagram; ?>,<?php endif; ?> <?php if ($global->linkedin): ?><?= $global->linkedin; ?>,<?php endif; ?> and so on ] } </script> and this is how it should look, if there is an entry: <script type="application/ld+json"> { "sameAs" : [ "https://www.facebook.com/company", "https://www.instagram.com/company", "https://www.linkedin.com/company", and so on ] } </script> <?php if ($global->facebook): ?>"<?= $global->facebook; ?>",\n<?php endif; ?> <?php if ($global->google): ?>"<?= $global->google; ?>",<br /><?php endif; ?> The double quotes work because I used single quotes for the the rest. The line break (\n or br) is not generated in source code. The code is output as text, maybe because it hangs in the echo? The source code looks as follows: "https://www.facebook.com/company",<br /> "https://www.instagram.com/company",\n https://www. How do I set line breaks correctly, in this combination?
  5. @cstevensjr I have the same question. I can't find it under General Support or Form Builder Support. Where the post was moved to?
  6. kaz

    if query

    @zoeck interesting, I didn't know that in an array the search is different
  7. kaz

    if query

    Funny, how an if statement behaves. I wanna check whether a field has content. So I asked about the field: if ($article->gallery_images) If yes, I only want to output only the first image as a preview in an summary page, that's why I only retrieve these first image: if ($article->gallery_images) { echo " <div class='' uk-grid> <div class='uk-width-1-5@m uk-width-1-1@s'> <img src='{$article->gallery_images->first->url}' alt='{$article->gallery_images->first->description}'> </div> <div class='uk-width-4-5@m uk-width-1-1@s'> $content </div> </div>"; } else { <div class='uk-width-1-1'> $content </div>"; } The query does not work, even if no data is uploaded to the gallery_images field, is else not displayed. Now the funny part: When I add ->first to the if query, else is displayed, the query will work: if ($article->gallery_images->first) { echo " <div class='' uk-grid> <div class='uk-width-1-5@m uk-width-1-1@s'> <img src='{$article->gallery_images->first->url}' alt='{$article->gallery_images->first->description}'> </div> <div class='uk-width-4-5@m uk-width-1-1@s'> $content </div> </div>"; } else { <div class='uk-width-1-1'> $content </div>"; } I have hardly any PHP experience, so perhaps I don't understand why this is the case, but: it surprised me in terms of logic.
  8. @ngrmm works great, thanks for the hint with a variable!
  9. A client would like to have a checkbox or similar for an image field in order to apply a style. echo " <img class='{$page->check}' src='{$page->image->url}'>"; I have thought about creating a checkbox, but it's not so easy because the class must given out in an echo. How to pass a class, a style in an echo?
  10. @gmclelland I have it in the /views folder, not /fields, because in PageTable I have to select a template. PageTable does not allow to select a folder, so my templates are in the /views folder 😉 I would prefer to have the widget templates in an own folder, but it's not possible with PageTable. This is the code of my bodysection file (PageTable Field): <?php namespace ProcessWire; // Loop through each element in the PageTable field foreach($bodysection as $section) { // Get the template of the page in the PageTable field $template = $section->template->name; // Depending on template, render the content switch($template) { case 'section-content': // "section-content" template rendered here echo $section->render(); break; case 'section-gallery': // "section-gallery" template rendered here echo $section->render(); break; case 'section-…': // and so on break; } } Only the Page IDs are received in frontend, at least the IDs are correct, yeah: 1122|1124
  11. Is there perhaps an official documentation for PageTable? I can't find anything in the forum posts explaining how to render PageTable templates? I placed two templates in the /views folder and inserted them in the Page Table field. The editor can now add the elements of the templates. The section-content is saved on a hidden page which I created separately in the admin area. My nameofpagetablefield does not transfer any data. echo $page->render('nameofpagetablefield'); There is no error, I don't understand where to look? But how do I use foreach to render different items / templates?
  12. @artfulrobot Thank you for these amazing screenshots, it's easy to understand. I'm sorry, but I have the solution from @teppo with a "ProFields: Page Table" field.
  13. I have done it this way, but I think the link is missing. I have a page table field section_blocks. As described, I did not select an >Details >Template. In the /fields folder I have a section_blocks.php <?= $item->render(__DIR__ . '/section-blocks/' . $item->template . '.php') ?> I render it in my basic template: <?= $page->render('section_blocks') ?> For this I have two two simple templates: /site/templates/fields/section-blocks/block_content.php /site/templates/fields/section-blocks/block_gallery.php When I open the page in the editor, I get the following error message: Please select a template before using this field. Please specify one or more columns in the settings before using this field. What I can't find in the configuration of the section_blocks field: Configure your Page Table field to save new items below aforementioned root path, and make sure that you only enable templates that you've created for this purpose. So the connection is missing, and I wonder, how do I set up the connection? What have I overlooked?
  14. I do different content sections with Repeater Matrix. Since there are more and more sections, I would like to choose another solution. I don't have any experience with Page Table, but based on what I've read, it seems like a possible alternative? My repeater matrix script is a foreach, so that the user can extend it as needed. <?php foreach($page->sections as $item) { if($item->type == 'content') { echo " <h1>$item->title</h1> $item->content "; } if($item->type == 'links') { echo " … "; } and so on } I can add the items of the above script as single templates for Page Table, and add them in a Page Table field (Details). In my base template I call the page table field, e.g. echo $page->render('sections'); On my first try, a child page was added, which I don't really want. The code from the template which I had added in the field (details) was not taken over either. In short, I need help. Can perhaps someone give me a little HOWTO on how to do this correctly? Maybe Page Table isn't suitable at all?
  15. @Nicolas great, it works perfectly!
×
×
  • Create New...