-
Posts
174 -
Joined
-
Last visited
-
Days Won
1
Posts posted by neophron
-
-
Hi guys,
in a website with a lot of fieldsetpages I want to show in this case accordions, only if a field (body) is populated.
This is my faulty code:
<?php if ($page->sectionfield_fa_membership->body) : ?> <section class="membership"> <ul uk-accordion> <li itemscope itemprop="mainEntity" itemtype="https://schema.org/Question"> <a class="uk-accordion-title" href> <p itemprop="name">Membership</p> </a> <div class="uk-accordion-content" itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer"> <div itemprop="text"><?= $page->sectionfield_fa_membership->body; ?></div> </div> </li> </ul> </section> <?php endif ?>
I'm getting this error: Attempt to read property "body" on null
The logic is based on this code:
<?php if ($page->body) { echo $page->body; } ?>
-
Thanks for this cool explanation! I converted an existing website to a multilanguage site with DE and EN. After finishing all steps, I noticed, that in all fields the english tab was the active one. But it had to be the opposite way. So I deactivated / uninstalled the Core -> Language -> Languages Support - Tabs module. Logged out and in and reinstalled the Languages Support - Tabs module. And voilà, now all DE tabs are the active ones.
- 1
-
Good day everyone,
I'm wondering if this cool module could help me with the following structure, where all »sub-home« pages have the same template:home (mother page) —> navigation that shows only all child pages from the mother page
- about
- contact
- news- sub-home A (template subhome) —> navigation that shows only all child pages from A
-- about A
-- contact A
-- news A- sub-home B (template subhome) —> navigation that shows only all child pages from B
-- about B
-- contact B
-- news B- sub-home C (template subhome) —> navigation that shows only all child pages from C
-- about C
-- contact C
-- news CI'm using the markup regions templating. Most child pages use the same templates.
-
8 hours ago, teppo said:
I get that the gist of this thread is "WP bad", but to be fair I've ran relatively often into the opposite issue in ProcessWire: an image or file that should've been uploaded once and then reused is instead uploaded to a whole bunch of separate pages, using loads of unnecessary disk space. ProcessWire doesn't by itself create a lot of unnecessary variations, but it is not uncommon occurrence either: years of code changes combined with badly configured image fields (no limit for image dimensions) can lead to major disk bloat.
Before I switched to PW, I worked with a german CMS (Contao). It stores all media in the classical way in an upload folder. I'm still managing such Contao websites, some of them are meanwhile about 10 years old.
e.g. among them is a Contao website with a lot of PDFs, that are updating every 3 or 4 months. I'm trying to organize them in subfolders, but meanwhile it's getting messy. And this is where PW is really useful.8 hours ago, teppo said:Worse yet is when someone decides that a file/image that is separately uploaded all around the place now needs to be updated everywhere. Oh the joy!
Long story short: there are cases for and against both central media/asset management and page based media/asset management, neither are perfect.
Looking back on my website projects, I must say, that the PW file-concept was for most clients a better solution. Some of them worked before with Contao and they appreciated the upload fields in the PW backend. If there is a need for reusing the same image on different places, PW offers some solutions. Recently I purchased this: https://mediamanager.kongondo.com
HAPPY NEW YEAR!
- 1
-
Recently I transferred a website from WP to PW. First I had to clone the WP site in order to install it on a different hosting company. It turned out, that this WP installation (about 6 main pages and 20 subpages) with a few images, had the size of about 1 GB! This video helped me: https://www.youtube.com/watch?v=tIurrwfsCOg&list=LL&index=32&t=474s
I found in the upload directory a lot of 7000px wide jpgs. Every time an image is uploaded, WP generates about 4 or 5 different size variations and keeps them all in the same directory.There were plugins installed, that all begged for an upgrade. Everywhere in the backend constantly informations from different sources popped up.
After I finished the new website in PW, I compared the amount of the generated html code. The PW code was about 80% smaller.- 3
-
On 10/30/2023 at 2:35 PM, BitPoet said:
Ah, should have mentioned that. wireRenderFile returns the rendered content, so you need to echo it or use <?= wireRenderFile(...) ?>.
Now for everybody, who looks how to include files from a subdirectory:
In site/templates/includes/menu_main.php render the file by: <?php echo wireRenderFile('includes/menu_main.php'); ?> -
10 minutes ago, bernhard said:
Sure. Either install RockMigrations and use the "PageListShowTemplate" tweak. Or have a look what it does and add a hook yourself: https://github.com/baumrock/RockMigrations/blob/main/tweaks/PageListShowTemplate.php
Or use custom page classes and use the getPageListLabel method. Also super easy!
Servus,
thanks, I'm going to check it out. -
8 minutes ago, ngrmm said:
@neophron you could to set your settings here
Setup > Templates > your-template > Advanced > List of fields to display in the admin Page List
And maybe you look into a css solution to hide it for non-superusers. But I don't know if that is possibleThanks for this hint. PW offers really a lot modifications.
This is part of the html backend structure, seen from a non admin:
<div class="PageListItem PageListTemplate_video PageListNoChildren PageListID1226 PageListStatusUnpublished secondary PageListStatusHidden PageListItemHover" data-numtotal="0" data-numchild="0"> <a href="#" title="/video-container/video-03/" class="PageListPage label"> <i class="icon fa fa-fw fa-video-camera"></i> Video 03 | video </a> ... </div>
It would be cool, if {template.name} could be wrapped in a display: not span, that is loaded only if a user is logged in.
-
1 hour ago, BitPoet said:
getRandom() by default returns a single item (Repeater item in your case). So the foreach tries to iterate over that single Repeater item's properties instead of an array of items. There are three solutions:
- Drop the foreach and just do "$item = $page->repeater_headline_movie_text->getRandom();" (Might error out if the repeater is empty)
- Set the $alwaysArray argument for getRandom: "foreach ($page->repeater_headline_movie_text->getRandom(1, true) as $item)"
- Or use "$page->repeater_headline_movie_text->findRandom(1)" instead, which always returns a RepeaterPageArray
Thanks a lot @BitPoet
Nr 3 works fine 🙂
-
I wanted to refresh this, cause meanwhile the new name of module is »Page List«.
Modules --> Core --> Page List --> {title} | {template.name}But recently I noticed, that adding an icon to a template removes the template name. And now I have two questions:
- Is there a way to show both?
- Is there a way to hide the template names for non admins?
-
25 minutes ago, ngrmm said:
@neophron why is code bad? Do you get an error or any output?
Trying to get property 'media_manager_v_single' of non-object
-
10 years later!
Searching for a getRandom() solution from a repeater, I stumbled upon this thread.
I have the repeater_headline_movie_text with the field media_manager_v_single. My goal is to render only one repeater item randomly.
This is my bad code:<? foreach ($page->repeater_headline_movie_text->getRandom() as $item) : ?> <article class="video_article"> <h3><?= $item->headline; ?></h3> <?php $out = $item->media_manager_v_single->each(function ($resource) { return "<video src='{$resource->media->url}' poster='{$resource->media->poster}' width='720' height='408' controls></video>"; }); echo $out; ?> <div class="textwrapper"> <?= $item->body_second; ?> </div> </article> <? endforeach; ?>
-
1 hour ago, adrian said:
At a quick glance, it feels like you are missing a level when getting the video. You need to get the video_field from the select_video, but instead you are getting video_field from $item. Does that sound right?
Hi Adrian,
thanks for your suggestion. Yes, now I see what's missing. The logic must be:
Select the page, check if there is a field video_field inside and render the content.And I think that this php-logic causes me headache 😕
-
Struggling with page reference inside repeater
Hi,
since the video files are usually bigger then some jpgs, I wanted to reuse uploaded video files on a website.There is a page reference field select_video inside a repeater. The file field for the videos is video_field.
In a hidden page "video-container" are hidden child pages. Each child pages has a single video. I want to show each video via the page reference (inside a repeater) on a different page.
In the field video_field under Basics -> Type the option Files is active.
This is my code, where only headline and body_second are rendered.
<? foreach ($page->repeater_headline_movie_text as $item) : ?> <h3><?= $item->headline; ?></h3> <article class="video_article"> <?php if ($item->select_video->id) : ?> <?php $file = $item->video_field; if($file) { echo "<video width='{1280}' height='{710}' poster='{$file->video_field->poster}' controls='controls' preload='yes'> <source type='video/mp4' src='{$file->video_field->url}' /> <track kind='subtitles' src='{subtitles}' srclang='de' /> </video> "; } ?> <?php endif; ?> <div class="textwrapper"> <?= $item->body_second; ?> </div> </article> <? endforeach; ?>
-
Hi,
maybe some of you already know this project: https://utopia.fyi
They offer a type-, space- and grid-calculator for fluid design, no breakpoints. All these are actually clamp-clalculators.
-
3 hours ago, BitPoet said:
Give wireRenderFile a try instead of wireIncludeFile.
Using wireRenderFile doesn't render the stuff. Using wireIncludeFile works right now.
No idea what's wrong cause there are no errors (even with tracy). -
21 hours ago, BitPoet said:
Give wireRenderFile a try instead of wireIncludeFile.
Thanks.
I think I found the error: It's the famous <?php namespace ProcessWire;
Solution:
all included php files should start with a <?php namespace ProcessWire;
And in my case now it looks like this:<?= wireIncludeFile('includes/menu_main.php'); ?>
-
Hi guys,
I'm struggling with including php files from a subfolder. Maybe because there are more then one solution.
I'm using the $config->useMarkupRegions = true; with the _main.php. Right now I have some php files that I include in the template files like this: <?php include('menu_main.php'); ?>Now I have this subfolder: /templates/includes
This won't work: <?php include('includes/menu_main.php'); ?>
Using <?php wireIncludeFile('includes/menu_main.php'); ?> works only with the menu_main.php file, but not with others.What would you suggest?
-
How about using the htaccess for this?
-
Hi,
years ago I build a website with about 12 subdomains. It’s representing an association with 12 local groups. There are 12 users, each user has access to only one subdomain. The current cms is Contao (a german cms), some of you probably heard about or worked with.
The problem now is a human one. Many users are uploading a lot of sh*t, such as a ton of almost the same gallery images, that are too big or too small. You can’t educate them by setting limitations like in the fields with PW. I found also whole html tables with inline styles, that were copied from somewhere and pasted into the editor.
So I’m wondering, if this would be a good strategy, to install PW with the multisite plugin and to rebuild the old website with all subdomains. Which problems could I face with 12 subdomains and 12 users, that should have access only to their subdomain pages?
Does anybody of you guys has some experience of this kind?
-
35 minutes ago, bernhard said:
Your logic is impossible.
If the page is a child of archive it can not be a child of the other pages
You're absolutely right. I wrote my question too hasty. I'm gonna find a different way for applying a color to a teaser.
-
Hi there,
meanwhile the client had a new wish and I need your help again.
An archive page shall contain children, which will be moved there manually.Structure:
archive (archive) --> shows teaser from child pages
child-page 02
child-page 01
child-page 03
child-page 01
child-page 01
child-page 02The classical way to echo child pages is by: <?php foreach ($page->children() as $teaser) : ?>
But I need again the data from the color_field mentioned above <?= $teaser->parent->select_color->title; ?>The logic now would be something like this: Find all children from parent=1223|1224|1225 and echo a teaser only if they are children from archive
-
Hi guys, 5 years later…
for separating the date components from a date field, I found this solution. This works fine.
<?php $d = strtotime($page->datefield); echo date('d', $d) . '<br>'; //e.g 8 echo date('F Y', $d); //e.g. November 2015 ?>
But I want to germanize the output. I tried this:
<?php setlocale(LC_ALL, 'de_DE.UTF-8'); $d = strftime("%d. %B %G", strtotime($veranstaltung->datefield)); echo date('%d.', $d) . '<br>'; echo date('%B', $d); ?>
But I'm getting an error: A non well formed numeric value encountered
In my config.php I have these lines:
$config->timezone = 'Europe/Berlin'; setlocale(LC_ALL, 'de_DE.UTF-8');
I don't know, if these settings from the date field are correct
- 1
-
26 minutes ago, bernhard said:
<?php foreach($pages->find("parent=1223|1224|1225") as $teaser): ?> <a href='<?= $teaser->url; ?>' class='teaser-angebot-wrapper <?= $teaser->parent->select_color->title; ?>'> <section> <h3><?= $teaser->title; ?></h3> <?php if($teaser->parent->id == 1223): ?> <p>Ausstattung: <?= $teaser->textfield_01; ?></p> <?php else: ?> <p>Wo / Wann: <?= $teaser->textfield_02; ?></p> <?php endif; ?> </section> </a> <?php endforeach; ?>
I've recently become a huge fan of the latte template engine (by the folks that made tracydebugger) as it produces so much cleaner output in your templates and that would be a perfect example:
<a n:foreach="$pages->find('parent=1223|1224|1225') as $teaser" class='teaser-angebot-wrapper {$teaser->parent->select_color->title}' href='{$teaser->url}' > <section> <h3>{$teaser->title}</h3> <p n:if="$teaser->parent->id == 1223">Ausstattung: {$teaser->textfield_01}</p> <p n:if="$teaser->parent->id == 1224">Wo / Wann: {$teaser->textfield_02}</p> </section> </a>
Thanks! Now it works fine ?
I'm going to have a look at this »Latte«
- 2
{Solved} FieldsetPage – show html structure only if a field is populated
in API & Templates
Posted
It was really a single typo, that caused these problems.