-
Posts
4,077 -
Joined
-
Last visited
-
Days Won
87
Everything posted by horst
-
Accessing PW API within a function (Newbie Question)
horst replied to tourshi's topic in API & Templates
Hi @tourshi, welcome to PW. If you want do "things" with / from a page in a function, you best pass the $page as parameter or get its handle with the wire() function: function getTitle($page) { $t = $page->title; function getTitle() { $page = wire("page"); $t = $page->title; But if you only want one of two field values, depending if it is populated or not, as I can see from your code, you don't need a function for that. You can use it directly in your template with an OR selector as follows: $t = $page->get("long_title|title"); This will give you the value of long_title if there is one, OR, if it is empty, it gives you the value of title. Coming back to the function: fastest way is to pass the variable into the function, because the variable is an object what is passed by reference. There is no drawback or overhead, its the fastest way. If you, for what ever reason, cannot pass a API variable to a function, you always can get there handles via the wire("nameofapivar") function. This works everywhere, but has a (very little) overhead. Also I don't think it is measurable with a few calls, (less than 100). -
anybody could show an example of how to use $config->ajax ?
horst replied to adrianmak's topic in Getting Started
If you prefer some type of delayed output, you also can use both (regular and ajax) very close together: $out = ''; $out .= {html head part}; $out .= {my menu content}; $out .= {some other content}; // her we come to the individual content if ($config->ajax) $out = ''; // delete all collected output til here and start new $out .= {my individual content}; //... collect until individual content is complete, then if ($config->ajax) { echo $out; // send it out as html exit(); // stop any further processing } // if it isn't a ajax call you collect also footer etc. $out .= {my footer content}; // send out the complete html page echo $out; -
Hi, the error in your first screen advices you to define $config->uploadTmpDir (in site/config.php) and ensure that it is writeable. So, I don't know MAMP and how it manages things, but I would simply try to find a place for uploads by try and error if there are no useful docs for Windows. For example you can try to create C:\MAMP\htdocs\tmp, and set this in your site/config.php $config->uploadTmpDir = 'c:/mamp/htdocs/tmp/'; // yes, you can use forward slashes, PHP and Apache on Windows converts this internally where needed, also try with trailing slash first! And if this doesn't work, go to that folder with the windows explorer and set it rigths to writeable for everyone as a quick and dirty test. Than try again. If this doesn't help come back here and tell us. (missing trailing slash for the directory ?) You may also try $config->uploadTmpDir = 'c:/windows/tmp/'; // traing slash !!
-
One way can be to not set an default icon to the template(s) but set it manually like here with other things: https://processwire.com/talk/topic/5609-display-a-template-icon-base-on-date-field/ I use this in a project where I need to show the workflow states and the current authors shortcut. There are used 3 different icons and 3 different colors. public function addHookAfter_ProcessPageListRender_getPageLabel($event) { $page = $event->arguments('page'); if ('aki-faq' == $page->template) { $iconTpl = $iconTpl1 = '<i class="icon fa fa-fw fa-file-text [_STATUS_]"> </i>'; $iconTpl2 = '<i class="icon fa fa-fw fa-check-circle-o [_STATUS_]"> </i>'; $iconTpl3 = '<i class="icon fa fa-fw fa-newspaper-o [_STATUS_]"> </i>'; if ($page->editStatus > 2) $iconTpl = $iconTpl2; if ($page->editStatus > 5) $iconTpl = $iconTpl3; $icon = str_replace('[_STATUS_]', 'editStatus' . $page->editStatus, $iconTpl); $kuerzel = str_pad($page->aki_bearbeiter->kuerzel, 3, ' ', STR_PAD_RIGHT); $bearbeiter = (0 == $page->aki_bearbeiter->id || false === $page->aki_bearbeiter) ? ' <span class="akiPageListItem kuerzel warning">---</span> ' : ' <span class="akiPageListItem kuerzel">' . $kuerzel . '</span> '; $event->return = $icon . $bearbeiter . $event->return; } }
-
"getModuleInfo does not exist" error even with .info.php file
horst replied to charger's topic in Module/Plugin Development
learned something new again! -
"getModuleInfo does not exist" error even with .info.php file
horst replied to charger's topic in Module/Plugin Development
it is xxx.info.json, not .info.php -
Adding an option to Image to select an output format
horst replied to MadHatter's topic in Wishlist & Roadmap
Pageimage Manipulator supports this: $image = $page->images->first()->pimLoad("suffix")->setOutputformat("jpg")->save(); -
dirname(__FILE__) points to E:\... and DOCUMENT_ROOT to C:\...
-
whats in the error logs of php and apache?
-
Buying modules now, just need your kind answer for this...
horst replied to Socrate Taiser's topic in Modules/Plugins
It's the sister from Google (1) and Google (3) Hey, welcome to PW! -
blank pages, - but with what HTTP response code? Which profile has you installed? I'm running PW on windows with apache2, too. No problems here. Where do you have the .htaccess file placed when running PW from root? Is it combined with other rules, or is it only the PW distributed one?
-
Not by design, was just on the ToDo, (erm, on the "forgotten" list). Also on the ToDo is to add some meta-headers and more content in regard of SEO. You are right with the impression, but the subtitle belongs to the brand, so I cannot drop it. And the whole paragraph is a (one) clickable link which points to the portfolio, where all three sections are available. So at least not completly wrong. But I'm always open for suggestions.
-
There seems to be something was changed with the newer smtp class that we have changed 2 weeks ago. But anyways, it seems to be fixed now. @Pete, please can you have a look to it? I haven't changed anything on the behave of To-Recipients, only CC and BCC.
-
-
PIA is only compatible with PW 2.5 and 2.6! in Github repo, the subheader at top: Module for ProcessWire 2.5.0+ and in the modules directory it has the appropriate checkboxes checked. When trying to direct install via PW 2.4, you have it on the install screen: So, with PW 2.5+ you will see more bold information when versions are mismatch, or "thumbs up icon" if they match fine. But at least, also with PW 2.4 all needed informations are on the right place(s). One more reason to update your PW version, we are on 2.6 stable for some weeks now ;-)
-
Do you have copied all files completely to the modules directory? Which version of PW and PHP do you use?
-
max image dimensions - "not a recognized image" [bug?]
horst replied to bernhard's topic in General Support
Send a "forceNew" => true together with your images options to override existing image variations. $options = array("forceNew" => true); $image->width(500, $options)->url; Or use PIAs global (sitewide) setting for "forceNew" (in PIAs module config page) and switch on PIAs forceNew just load the page(s) with this image(s) again switch off PIAs forceNew -
I believe I have setup my Github the wrong way, I get notify messages for allmost everything, but not for issues of my own repos. I haven't seen it, but will look into it now.
-
I have enabled preloading with lazysizes. Does this "feel" better?
-
Hhm, I see. You are right. With the second load of an image, the lazysizes is contra productive. Is there a way to combine both? Lazyloading for first display, and local cached version afterwards?
-
I only have Chrome 43, there it is fixed. I have added it to the stylesheet. Thanks!
-
Thats how lazysizes works. One can use lowres images or blank (1x1 px transparent gif as base64 data) for images beneath the fold. The images are cached, but only gets loaded when you scroll down. EDIT: And yes I think it is worth to have lazy loading here, at least if one is on mobile with a small connection.
-
NOGAJSKI FOTOGRAFIE I have relaunched my homepage. I don't remember exactly how many versions I may had since I launched my first homepage in 1999, but for me, the new one seems to be the cleanest and fastest. At least its the one with the best backend ever. (PW 2.6) The layout of all pages, including the slideshow, is usable from (300 x 260 px) up to bigger desktops (27''). I have tried to satisfy google PageSpeed, but only in a medium range. Other tools than googles do a more in depth analysis and show much better detailed results. But anyway. All pages uses one sitewide css file and one sitewide js file. Only the portfolio slideshow loads an additional js and css file too. (The server is setup to force browser caching, so with the second page view, no js or css dependencies need to be downloaded.) And ProCache is used! (what else) Besides my images API tools I use delayed output via Spex. CSS framework is pocket-grid and on the JS side I use LazySizes, Vegas and the new Photoswipe 4. Thats all. http://nogajski.de/ Here are some screens with minimal viewport (300x260): and here are two medium screens:
-
I'm a lazy writer. But you are right, named is more future save.
-
It works as always with params: $inputfield = $event->object; $pagefile = $event->arguments(0); $id = $event->arguments(1); $n = $event->arguments(2);