-
Posts
1,065 -
Joined
-
Last visited
-
Days Won
11
Everything posted by Zeka
-
$morep = $featured = $page->siblings("template=partner, limit=3, sort=random", false); if($morep->count() < 3) { $morep->import($page->closest("template=category)->children("template=partner, id!=$page->id, limit=3, sort=random") }
-
if($page->matches("has_parent=/blog/posts/")) { }
-
Create page name with multiple consecutive dashes
Zeka replied to bmacnaughton's topic in API & Templates
Okey, I see. From sanitizer docs: * Modules may also add methods to the Sanitizer as needed i.e. $this->sanitizer->addHook('myMethod', $myClass, 'myMethod'); So you can add custom sanitizer method and then hook __construct method of InputfieldName and set your custom method for some pages https://github.com/processwire/processwire/blob/master/wire/modules/Inputfield/InputfieldName.module#L19 -
Create page name with multiple consecutive dashes
Zeka replied to bmacnaughton's topic in API & Templates
@bmacnaughton Not sure, but maybe you are looking for allowDoubledReplacement (bool): Whether to allow two of the same replacement chars [-_] next to each other (default=false). See options argument https://processwire.com/api/ref/sanitizer/name/ -
@MilenKo $recipesCategoriesSelector = $page->recipe_categories->implode("|"); $related = $pages->find("template=recipe, recipe_categories={$recipesCategoriesSelector}, sort=random, limit=4);
-
@Marcel Stäheli Actually I checked whether I get value from $page->localName($user->langauge); I checked it in three languages and even with activating/deactivating it in page settings. So even if a page is not active for the current language I still got language specific name. Second: Why not use $tagName = $sanitizer->name($tag) if($pages->get("/tags/{$tagName}"}->id) { ... } If I'm not mistaken it looks for in all languages.
-
Hi @Marcel Stäheli For the first question: Just tested and it works as expected in my installation. For the second: What is the purpose of this kind of check?
-
Hi @MilenKo Maybe you can rely on some additional field like "ingredients" when a recipe belongs to multiple categories?
-
Hi @xfroggy mostly depends on your needs. I was thinking that you need separate domain or subdomains for every site/user. If so, I think that multisite module is the way to go. I didn't use it by myself, but read that it is possible. As another variant, you can create additional separate page for every user ( do it in register step ), and then put all users specific pages under its page. So you can create next url structure of your site: site.com/xfroggy site.com/xfroggy/about/ site.com/xfroggy/blog/ site.com/xfroggy/blog/article/ site.com/xfroggy/contacts/ site.com/zeka/ site.com/zeka/about/ ...
-
Hi @Tyssen I think that @abdus method is more natural for PW, in the same manner, you can implement sitemap.
-
https://github.com/dsdsdsdsdsds/InputfieldImageThumbs/blob/4aaa3362ea11468d3f6b4f69748da8464910fb3a/InputfieldImageThumbs.module
-
Hi @xfroggy There is Mutisite Module https://github.com/somatonic/Multisite/tree/dev
-
Hi, all! Currently, I use wireRender approach, so in template files, I define all logic and in $viewData array I pass all needed data to my view file through wireRedner method. My question, actually not directly relative to PW, but to data structuring. Let imagine that we have some page with some repeater field and images field. In template file, I iterate through $page->images and create new flat array $images = []; foreach ($page->project_images as $image) { $images[] = array( "desc" => ($image->description) ? $image->description : $page->title, "thumb" => $image->size(300, 300)->url, "large" => $image->width(800, ['upscaling' => false])->url ); } and then pass this array to my view $viewData["images"] = $images; $content = renderView("project", $viewData); and in the view file, I iterate through $images array <div class="project__images"> <div class="project__images-row" data-lightgallery> <?php foreach ($images as $image): ?> <div class="project__image-box"> <a class="project__image-link" data-lightgallery-item href="<?= $image["large"]; ?>" title="<?= $image["desc"]; ?>"> <img class="project__image" src="<?= $image["thumb"]; ?>" alt="<?= $image["desc"]; ?>"> </a> </div> <?php endforeach; ?> </div> </div> <?php endif; ?> So I do for all complex and simple fields. I like this approach, but I have feelings that I overcomplicate things because I can just simply pass $page->images to view and iterate through this WireArray. So my questions are: Due to this approach, I need to iterate several times to output just one field, does it influence performance ( in a case of some complex repeater field)? What do you think about it? Should I do it in the way I do or just pass WireArray? Maybe you can share your vision and approach about it. P.S. I know that my questions look a little bit dumb.
-
Hi @BitPoet Are there any news?
-
Hi @Vikestart You should use all power of selectors for that. For example, if you want to output your list of post on home page, you can do $posts = $pages->get("/categories/)->children("sort=-data"); Read more about selectors in PW https://processwire.com/api/selectors/
-
About session fingerprint and load balancer IP change
Zeka replied to Karl_T's topic in General Support
Hi @Karl_T Why not $config->sessionFingerprint = false; ? -
Hi @Naz Possibly it's done via hooks or with a custom module. Try to look in these files site/init.php site/ready.php site/finished.php
-
HI @nabo // $page - is page with store template $dayRepeaters = $page->repeater_field->find("days=friday"); foreach($dayRepeaters as $rp) { echo $rp->hours; } Does it suit your need?
-
Hi @Tyssen https://www.andrewversalle.com/blog/environment-specific-robotstxt-files
-
Creating page from form based on template fields (front end)
Zeka replied to fredbob's topic in API & Templates
Hi @xfroggy I'm not sure about this at all. $np->parent = $pages->get($user); // set the parent You are trying to set user page as parent for new page. Users pages can't have children.- 1 reply
-
- 1
-
HI @nabo It looks like you can use subfield selectors: https://processwire.com/api/selectors/#subfield $pages->find("template=store, repeater_fied.hours=10");
-
Hi @benbyf I'm using it without any errors https://github.com/processwire/processwire/blob/d935e9b6995124d76e6fda17fd47ab46dc4d3a3c/wire/core/Functions.php#L256
-
Hi @holmescreek Do you use this code on pages with "testimonials" template? If no, you should use $testimonials = $pages->get("/testimonials/)->testimonials_repeater->getRandom(4); foreach($testimonials as $ts) { //code }
-
I'm using hreflang tag in head and sitemap with URLs for all languages and don't have any problems with indexation.
-
Thank you @LostKobrakai for you answer!