-
Posts
6,808 -
Joined
-
Last visited
-
Days Won
159
Everything posted by Soma
-
How to retrieve possible pages list in a Page field
Soma replied to tsdtsdtsd's topic in General Support
slkwrm, yes kinda, but won't work out of context and only if there's a page selected already. -
Not sure I understand Might be like this? $res = $pages->find("template=topic, topic=$page->children, sort=-created, limit=10");
-
How to retrieve possible pages list in a Page field
Soma replied to tsdtsdtsd's topic in General Support
There's no simpler way. However I would write: $children = $pages->get($fields->select_architect->parent_id)->children; -
ProcessWire CheatSheet Poll - How much do you use it?
Soma replied to Soma's topic in API & Templates
Thanks guys. Originally I had some special stuff in there and things like pager etc. , but because Ryan had some gripes with it, I removed it. So I'm interested what Ryan thinks too. -
ProcessWire CheatSheet Poll - How much do you use it?
Soma replied to Soma's topic in API & Templates
Thanks for the post Martijn. Glad to hear it serves its purposes. One reason it's not in there, is because language support was still in development and moreover it's not core, it's a third-party module and need to be installed (although it's in the distribution). There's couple things not in the cheatsheet that are not permanent modules i.e. like the comments, pager etc. I'm not sure if those distributed modules should be added somehow or make a separate sheet. What you guys think? -
However, I'm not sure you really want to use that fieldtype as it is limited to special types of modules based on the parent class. May I suggest using a regular page field with ASM select inputfield or alike, and create pages for each module you want to be able to select. Then use the title on those pages to load the module in the frontend. So you could even have multiple modules and sort them the way you want them to load. Depends on what you're up to. // when multiple select foreach($pages->selected_modules as $mod) { $module = $modules->get($mod->title); $module->render(); } //or just a single select $module = $modules->get($page->selected_module->title); $module->render();
-
The module reference is shown if you enable advanced mode in the config.php. Then you can select when creating a new field.
-
The module has no url param functions so I'm a little surprized it changes language, so this may from PW itself or you did something to get the url param? However you can simply do something like this: Somewhere in the template I have this before the language switch $lang = $user->language; $langname = $lang->name == 'default' ? 'en' : $lang->name; Then the language switch links // get users current language $lang_temp = $user->language; // set language to default $user->language = $languages->get("default"); $st = $langname == 'en' ? " class='on'" : ''; echo $page->language_published->has( $pages->get("/en/") ) ? "<a$st href='{$page->url}'>EN</a>" : ''; // set language to german $user->language = $languages->get("de"); $st = $langname == 'de' ? " class='on'" : ''; echo $page->language_published->has( $pages->get("/de/") ) ? "<a$st href='{$page->url}'>DE</a>" : ''; // set users language back $user->language = $lang_temp; Like this, the "$page->url" will return the language url already, if the users language is switched while creating the links for each language. So no need for urls params, cookies, sessions or anything. The page field "language_published" references the proxy language pages, so we can easily check if the language is really published (checked), which means it holds the proxy page. Since it's a page reference field we can simply use $page->language_published->has() method. Edit: added missing script needed before.
-
Looks really great! Seems like a well created tool to save time. However regarding different sizes, is it possible to automate creation of various sizes, and how will it behave with filters when scaling? Are you using vectors for this because pixel icons will not work well? I know it says something that it can do duplicates but not much more infos on this. One note: make the video playlist off, after watching the video it shows slash games videos. You can turn it of or add your own playlist with params. Edit: BTW: I just bought it!
-
Getting some pages, except the current one
Soma replied to Michael van Laar's topic in API & Templates
You can't put php variables inside single quote string, only double quotes are getting parsed. No need to use remove(), the selector is the easiest way. -
F wooot PW isn't good at? You mean for on a new site? Something like Profile Exporter could come in handy. Also you could pretty easy create a field template creator via API. Limitless and simple. Edit: For locally tasks, also there's clone feature in PW. Go to /site/config.php and enable advanced mode. Welcome to advanced pro mode! Now you can under the tab advanced, clone fields and templates using a checkbox and save, then rename.
-
Use google to search processwire.com "site:processwire.com keyword"
-
It's there to tell PW that the value has changed.
-
I'm not sure I understand. You don't check if there's an image and without debugging turned on in site config it may fail silently. Hard to help without seeing the output and more. However, to check if a image is there you could change to something like this <?php if(count($tour->images)): ?> <img src="<?php echo $tour->images->first()->size(200,0)->url; ?>" width="200" class="picture"> <?php else: ?> <p>(NOIMAGE)</p> <?php endif; ?>
-
I also tried something similar as your code, but it didn't work regardless of what I tried. I think I missed the $page->images->sort("sort"); and to do the trackChange on the field instead of the sort or page. Thanks Ryan for clarifying. I don't get why removing and readding would be a problem. Seems to work well. Edit: Just wondering, but why does echo $image->sort not output anything?
-
What are you using? This isn't php... No, you want to do: <img src="<?=$project->images->first()->size(200,0)->url;?>" width="200" /> or <img src="<?=$project->images->first()->widht(200)->url;?>" width="200" />
-
diogo, sure $img = $page->images->first(); $page->images->remove($img); $page->images->add($img); $page->save(); and the first image is at last position
-
I think the only way is to remove the images and add them in the new order again. So you could construct a form with this in mind.
-
I think you're looking for something like this: <?php foreach($page->children as $project) { echo "<h2>{$project->title}</h2><p>{$project->body}</p>"; foreach($project->images as $img) { echo "<img src='{$img->url}'>"; } } ?> $project->images is an array if the images field is set to multiple. If it's a limited to 1 image field your code would work. Or to get for example the first image from the stack, you could just access it using $project->images->first()->url;
-
As a php notice where the field label text output would be. Maybe your server has notices disabled.
-
When I tested your code 1:1, and turned on debug. It showed me the warning that the $language var doesn't exist.
-
Ah just posted same time. You should then do this: The default would be "". Field labels use "anno1299" where 1299 is the id of the language. The default would be just "anno"; $language = ''; if($input->get->language) { // user clicked on a link to set the language $name = $sanitizer->pageName($input->get->language); $language = $languages->get($name); if($language) $session->language = $language->name; } if($session->language) { // language is defined in user's session $user->language = $languages->get($session->language); $language = $languages->get($session->language); } Always remember to try to debug. You can then see errors and warnings you don't see without. Turn it on in the site/config.php
-
Not sure, have you debugging turned on?
-
Looks ok to me. I can switch language just fine.
-
Nesting Fieldset and FieldsetTab doesn’t work
Soma replied to Michael van Laar's topic in General Support
Ryan, according to his post, he already tested default theme.- 5 replies
-
- fields
- FieldsetOpen
-
(and 1 more)
Tagged with: