Edward Ver
Members-
Posts
22 -
Joined
-
Last visited
Everything posted by Edward Ver
-
Using different javascript for multilanguage website
Edward Ver replied to Edward Ver's topic in General Support
That works! Thank you so much! <?php if($user->language->name == "en-gb"): ?> <script src="<?php echo $config->urls->templates; ?>assets/scripts/cookieconsent-init-en.js" async></script> <?php else: ?> <script src="<?php echo $config->urls->templates; ?>assets/scripts/cookieconsent-init-no.js" async></script> <?php endif; ?> -
How to load a different js for another language? I'm new to PW, and my first time developing a multi language website in PW too. I came across a problem where I have to load a different js for english for example. Norwegian (default lang): <script src="<?php echo $config->urls->templates; ?>assets/scripts/cookieconsent-init-no.js" defer></script> How to load it if the url is mydomain.com/en. Thank you in advance.
-
OK, did it. I just added this: <?php if( $child->id == $pages->get("/news")->id ): ?> <li <?php if ($child->id == $page->rootParent->id): ?> class="current"<?php endif; ?>><a href="<?= $child->url ?>"><?= $child->title ?></a></li> <?php else: ?>
-
@Sanyaissues How not to show the Submenu of a "Blog" parent menu. I tried to search the forum and found no answers. Thanks.
-
Thank you Sanyaissues. It's working perfectly now. Again, thank you for your time. Highly appreciated.
-
This is the one that works for me: <?php if ($page->tags): ?> <?php $items = $pages->find("template=work_details,id!=$page,tags='{$page->tags}'"); ?> <?php foreach($items as $item): ?> <div class="w-full py-16 bg-slate-50"> <div class="max-w-[89.5rem] md:mx-auto"> <h3 class="w-full !mt-0 mb-6 text-2xl text-center ">Related Projects</h3> <div class="flex flex-row flex-wrap items-center justify-center gap-4 lg:flex-col "> <?php foreach($item->work_hero_repeater as $work_hero_repeaters): ?> <div class="relative group"> <div class="overflow-hidden"> <img class="lozad w-full rounded-sm mt-0 lozad group-hover:scale-105 transform-gpu group-hover:saturate-150 transition-all duration-[600ms] " data-src="<?= $work_hero_repeaters->work_hero_image->getCrop('gridsquare')->url ?>" alt="<?= $work_hero_repeaters->work_hero_image->description ?>" > </div> <h5 class="pt-5 text-xl font-gloock"><?= $work_hero_repeaters->work_client ?></h5> <p class="flex-1 px-5 text-left font-raleway md:px-0"><?= $work_hero_repeaters->work_hero_subheading ?></p> <p class="top-0 left-0 hidden w-full h-full"><?= $work_hero_repeaters->tags ?></p> <a class="absolute top-0 left-0 w-full h-full group" href="<?= $work_hero_repeaters->pager_link->url ?>"></a> </div> <?php endforeach; ?> </div> </div> </div> <?php endforeach; ?> <?php else: ?> <?php endif; ?> I hope someone will find it useful. BTW Sanyaissues , How do you change it to accept more than 1 tag. If I use 2 tags e.g: Illustration , Logo, it does not work.
-
Well, it was silly of me. The Field "tags" was inside a repeater of the page template. I move it to out of the repeater, and it works now. Hey, don't judge me, I'm still learning :P. Thank you for your precious time Sanyaissues
-
Just one more issue, Yes, each tag field only has one tag. Even though each page has e.g: Page1 Page2 They all show on a page. I only want pages with the same tag visible on a page. Any ideas? or I'm doing something wrong. Thanks in advance
-
Thank you very much Sanyaissues. That works like a charm. Still learning PW, and lovin it so far.
-
Hi Guys, I want to display pages with the same tag. But nothing is showing. I'm new to this and I'm no PHP DEV. Any help to guide me to the right approach will be a great help. Project details page (work_details.php template) - work_hero_repeater (repeater) - tags (text field) - client_name (Text field) - hero_image (Image Field) <?php $items = $pages->find("template=work_details, tags=$page") ?> <ul> <?php foreach($items as $item): ?> <?php foreach($item->work_hero_repeater as $work_hero_repeaters) ?> <li><?= $work_hero_repeaters->work_hero_image->getCrop('hero')->url ?> <a href="<?= $work_hero_repeaters->pager_link->url ?>"></a> </li> <?php endforeach; ?> </ul>
-
Got the idea and it works. Thank you very much!
-
Accessing fields in Repeater outside of page?
Edward Ver replied to V7dev's topic in General Support
Opp wrong post -
Hi All, I'm still learning PW, and loving it. But, I'm no PHP coder. My Problem is how to output fields from another page inside a repeater. <?php $showcase = $pages->find("template=work_details") ?> <?php foreach($showcase as $showcases): ?> <div> <p class="pb-2 text-left"><?= $showcases->work_hero_subheading ?></p> // This is inside a repeater called "work_hero_repeater" </div> <?php endforeach; ?> But there is no output. Thank you for any help.
-
I tried your suggestion but I get an error. "Snapsicles… Fatal Error: Uncaught Error: Call to undefined function wireCount()" <?php $blogger = $pages->find("template=blog_entry,featured_post=1"); // my template ?> <?php if (wireCount($blogger)) : // Check if there are any bloggers ?> <?php foreach ($blogger as $bloggers) : ?> <?php if (wireCount($bloggers->blog_entries)) : // Check if there are any blog entries ?> <?php foreach ($bloggers->blog_entries as $blog_entry) : // my repeater field ?> <div> <a href="<?= $blog_entry->url ?>"> <h1 class="text-xl"><?= htmlspecialchars($blog_entry->title) ?></h1> </a> <a href="<?= $blog_entry->url ?>"> <img src="<?= $blog_entry->blog_main_image->getCrop('blogsmall')->url ?>" alt="<?= $blog_entry->blog_main_image->description ?>"> </a> <?= $sanitizer->truncate($blog_entry->blog_text, 100, ['type' => 'sentence', 'keepFormatTags' => false]) ?> <p class="test_to_show_value_of_featured_filed"><?= $blog_entry->featured_post ?></p> </div> <?php endforeach; // End of blog_entries loop ?> <?php endif; // End of blog_entries check ?> <?php endforeach; // End of bloggers loop ?> <?php endif; // End of bloggers check ?>
-
So silly. I placed the $featured_field inside the repeater. Solved
-
Hello. I'm learning PW and I have a Blog page which shows blog entries and a featured blog using a field. But if I use the $field featured_post=1, no page is showing. Using limit=1 works fine. <?php $blogger = $pages->find("template=blog_entry,featured_post=1"); // my template foreach($blogger as $bloggers) { foreach($bloggers->blog_entries as $blog_entry) { // my repeater field echo "<div><a href='{$blog_entry->url}'><h1 class='text-xl'>{$blog_entry->title}</a></h1>"; echo "<a href='{$blog_entry->url}'><img src='{$blog_entry->blog_main_image->getCrop('blogsmall')->url}' alt='{$blog_entry->blog_main_image->description}'></a>"; echo "{$sanitizer->truncate($blog_entry->blog_text , 100, array('type'=>'sentence', 'keepFormatTags'=>false /* true or false */))}"; echo "<p class='test_to_show_value_of_featured_filed'>{$blog_entry->featured_post}</p>"; echo "</div>"; }} ?> Any help will be very appreciated. Thanks.
-
Thanks a lot. Very much appreciated.
-
I have multiple layers on repeaters which must have unique or descending numbers. How do you it in processwire? I'm still new to Processwire, and it looks promising so far. I just need an auto numbering for ex: slider-layer-[Code here]. <div id="slider-layer-1">Layer 1</div> <div id="slider-layer-2">Layer </div> <div id="slider-layer-3">Layer 3</div> Thanks
-
@Sanyaissues Thanks a lot. That works like magic.
-
Sadly, it did not work as expected. Sorry for the confusion, but i have added the classes. Your code html output: <ul class="menu-main md:text-[16px] text-[18px]"> <ul> <!-- Loop through each child of the homepage --> <li> <a href="/laser-treatments/" class="menu_link">Laser treatments</a> <!-- Check if the child has sub-children --> <ul class="sub-menu mega-menu"> <!-- Loop through each sub-child --> <li class="menu-item-has-children"> <a href="/laser-trstments/achilles/">Achilles</a> </li> </ul> </li> <li> <a href="/kontakt-oss/" class="menu_link">Kontakt oss</a> <!-- Check if the child has sub-children --> </li> </ul> </ul> The output html should be: <ul class="menu-main md:text-[16px] text-[18px]"> <!-- If the parent has HAS child, it should output this as well. But with the child menu --> <li class="menu-item-has-children"><a href="#" class="menu_link ">Laser treatment<i class="text-lg icon-chevron-down align-[-2px]"></i></a> <div class="w-full border-t-2 rounded-md md:w-9/12 sub-menu mega-menu border-rose-600 max-w-[1280px] "> <div class="list-item"> <ul class="grid grid-cols-1 gap-1 lg:grid-cols-3 megamen--seclevel lg:grid-flow-col md:grid-rows-1 lg:grid-rows-11"> <li class="w-full"> <a class="" href="/laser-treatment/acne">Acne</a> </li> </ul> </div> </div> </li> <!-- If the parent has no child, it should output this --> <li><a href="/Contact-us">Contact us</a></li> </ul> So close...thanks.
-
Wow, The community of PW is awesome. Thank you Sanyaissues. I will try it later and give a feedback. Thank you so much again.
-
Hello, I'm new to ProcessWire and I love using it so far. Using Runway CMS for years, It's simply easy to use both for myself and the client. I'm almost finish with a project, but stuck on the menu. I'm not good in PHP, so I will need a bit of help. My menu structure: Home - Laser treatment -- Acne -- Etc... - Contact us HTML: <nav class="menu"> <ul> <!-- If the menu has child --> <li class="menu-item-has-children"> <!-- notice the href="#" below with no real url value --> <a href="#" class="menu_link ">treatments<i class="icon-chevron-down"></i></a> <div class="sub-menu mega-menu"> <div class="list-item"> <ul> <li> <a href="/laser-treatment/acne-kviser">Acne</a> </li> </ul> </div> </div> </li> <!-- If the menu has no child --> <li> <a href="/contact-us">Contact us</a> </li> </ul> </nav> I have tried menuBuilder, But it does not meet my menu structure. As well as MarkupSimpleNavigation. Any help will be appreciated... Thanks in advance