-
Posts
6,798 -
Joined
-
Last visited
-
Days Won
158
Community Answers
-
Soma's post in Problem when moving site to hosted server was marked as the answer
Have you deleted cache? /site/assets/cache/ ?
I don't know why MarkupSimpleNavigation wouldn't load.
-
Soma's post in getModuleInfo singular and permission was marked as the answer
You'll find what you ask here http://wiki.processwire.com/index.php/Module_Creation
-
Soma's post in Multi-Language - Active Checkboxes and 404 Page was marked as the answer
You should try switch wire folder for the latest dev version, I think all those issues were recently fixed but only available in dev.
-
Soma's post in All Pages was marked as the answer
erm
foreach($pages->find() as $p) { echo "<p>{$p->url}</p>"; } returns nothing... but
foreach($pages->find("*") as $p) { echo "<p>{$p->url}</p>"; } returns all. While... foreach($pages->find("has_parent!=2") as $p) { echo "<p>{$p->url}</p>"; } would exclude pages under "/processwire/" admin pages. But maybe something also some restriction to template(s) would be good. foreach($pages->find("template=basic-page|article|news") as $p) { echo "<p>{$p->url}</p>"; } -
Soma's post in Create fieldset from API was marked as the answer
Aah, so you want to use them for templates in the admin?
How about:
$opener = new Field(); $opener->type = new FieldtypeFieldsetOpen(); $opener->name = "myfieldset"; $opener->label = "Open fieldset"; $opener->save(); $closer = new Field(); $closer->type = new FieldtypeFieldsetClose(); $closer->name = "myfieldset" . FieldtypeFieldsetOpen::fieldsetCloseIdentifier; $closer->label = "Close an open fieldset"; $closer->save(); $tpl = $templates->get("custom"); $tpl->fieldgroup->add($opener); $tpl->fieldgroup->add($fields->get("body")); $tpl->fieldgroup->add($fields->get("counter")); $tpl->fieldgroup->add($closer); $tpl->fieldgroup->save(); -
Soma's post in "Caching" pages field in other template was marked as the answer
Not sure what's about the cache thing? Do you have cache on templates?
Well it's a naive way, but if you don't go to thousands or ten thousands of tags and articles, you should be fine. I have pretty large sites with lots of things happening like this and I don't even need caching because it's so fast.
You can always create a custom SQL query, and join the tables you need.
Creating a module isn't complicated or lot of work at all! It same as you code in the front-end and you already know how to do it.
Here's a module done in 2 minutes and half the code is yours from above:
<?php class TagsHelperAuthor extends WireData implements Module{ public static function getModuleInfo(){ return array( 'title' => 'TagsHelperAuthor', 'version' => 1, 'singular' => true, 'autoload' => true ); } public function init(){ $this->pages->addHookAfter("save",$this,"hookPageSave"); } public function hookPageSave(HookEvent $event){ // get current page saved $page = $event->argumentsByName("page"); if($page->template == "article"){ // save tags to page field on author page or any page $authorPage = wire("pages")->get("template=author, name=Authorname"); $authorPage->tags->removeAll(); // remove all tags first $authorTags = new PageArray(); $allTags = wire("pages")->find('template=tag'); foreach ($allTags as $tag) { if(wire("pages")->count("template=article, tags=$tag")) { $authorPage->tags->add($tag); } } $authorPage->save("tags"); // save only the field of the author page } } } Not tested but should give you a hint.
Edit: The idea is on every Article save, you update the authors "tags" field and add/save them there. You would just have to adapt it as I don't know your structure exactly.
(Changed the $pages to wire("pages") because it's in a function.)
-
Soma's post in Using PW on Sourceforge was marked as the answer
It's working now, I had to set the rewrite base (uncomment)
Rewritebase / But as I said already in the PM, the permission on those accounts for apache and ftp user seem to create problem with not allowing to delete files over ftp created by php. Common problem with shared hostings. I deleted the files on server then with a php script, and installed a fresh install 2.3 stable. It seems all working with image upload. There's seems to be some limitations with that hosting in terms of memory and so on and the sftp is slow as hell.
A little more infos seem to be found here: https://sourceforge.net/apps/trac/sourceforge/wiki/Project%20web%20and%20developer%20web%20platform
-
Soma's post in Pagination for thumbnails from three different albums was marked as the answer
You could use my ImagesManager module which is made for use cases like a photo portfolio. Every image is created as a page and each gallery would be a category.
It would be a childs play to setup pagination and searching. Plus you can have as much meta data added as you like and all is searchable same as with using pages.
-
Soma's post in Individual image-field widths (float / display inline) was marked as the answer
Ok think I got a way to change the axis on sortable. Problem was that PW only inits the sortable for list greater than 1. So I got an error with the script that it can't set the "option" prior to initialisation. I made it work with:
$sortableLists = $(".InputfieldFileList"); $sortableLists.each(function(){ if($(this).children('li').size() > 1) { $(this).sortable( "option", "axis", "none"); } }); -
Soma's post in Image input field resizing on upload was marked as the answer
1. The upload max width and height setting is a way to avoid having the user upload 4000x10000px images. Remember it's a "max" size setting not a "thumbnail" setting. See it more as a original image that should be un-cropped. This keeps it flexible and simple to start with and if you maybe want to change the image size you still have the original image. Note that there's also several API calls in the image file to check for original and variations.
Theres modules or simple ways for creating cropped images
- as per Thumbnails module http://mods.pw/1b
- or to requires a certain format http://processwire.com/talk/topic/3476-fixed-image-size/?p=34110 (add "min" size settings to image fields)
- or a way to resize images on upload using simple module http://processwire.com/talk/topic/3718-lots-of-images-to-resize-timeout-in-frontend/?p=36291
2. Again it's not meant as a cropping setting for uploaded images. It works this way that if you set width "1000" and height "500" the image upload will be resized either in with or height or both depending on which side is larger than 1000px or 500px. That's why it checks both separate, at least I think so.
3. Most of the times you upload images and on output in the template file you generate the image size $image->size(520,261)->url and it will only create it if it's not already found and it will also recognize your crop settings. It creates a new copy and names it with the size you specify beside the original. This is the most straight forward way to work with images and there's not much more about it. But the system still allows to build on that and extend and change behavior of the image field if you wish.
-
Soma's post in Lots of images to resize -> timeout in frontend... was marked as the answer
This is the only way I know to create different sizes when uploading images:
<?php class ImageCreateThumbs extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'ImageCreateThumbs', 'version' => 100, 'summary' => '', 'href' => '', 'singular' => true, 'autoload' => true ); } public function init() { $this->addHookAfter('InputfieldFile::fileAdded', $this, 'sizeImage'); } public function sizeImage($event) { $inputfield = $event->object; if($inputfield->name != 'images') return; // we assume images field $image = $event->argumentsByName("pagefile"); $image->size(120,120); $image->size(1000,0); } } https://gist.github.com/5685631
What I don't know is if it really makes a difference (I guess), and if using drag and drop ajax upload and old school upload would process image one by one.
My suggestion is to also upload image already in 1000x* pixels because if they upload 3000+ px images it will just takes a lot longer.
-
Soma's post in Down-/Uploads on a "per user" policy was marked as the answer
You could use the config options for page secure files...
$config->pagefileSecure = true; $config->pagefileSecurePathPrefix = '-'; and make unpublished pages and their files will not be accessible via url.
So you could create child pages under the users page with a file field, and leave those pages unpublished. The assets directory will be prefixed with "-" which is restricted by htaccess.
But then you can use a passthru script to send the file to the user if certain requirements are given using wireSendFile();
So for example construct the download link to the file like this on a page the user can see.
<a href="/download.php?user=1007&file=filename.pdf">Download file</a> and in download.php with something like this for the passthru and user check
// bootstrap PW include("./index.php"); // make sure user is logged in if(wire("user")->isLoggedin()){ $file = $_GET['file']; $userid = $_GET['user']; $userpage = wire("pages")->get(wire("user")->id); if($userpage->id != $userid) die("no access"); // make sure it's the user if($filepage = $userpage->child("include=all")){ // since page is unpublished we add include all // get the file from the page $filename = $filepage->images->get($file)->filename; if(!$filename) die("download not found"); // send file to browser wireSendFile($filename, array('exit' => true)); } else { die("no user page found"); } } else { wire("session")->redirect("/somepage/"); } -
Soma's post in jQuery serialized string to PHP array was marked as the answer
Just use
isset($input->post->list)
-
Soma's post in Permissions: Prevent a group from deleting was marked as the answer
Then you would maybe create another role for them with only delete permission and remove the delete permission from the other role. Then assign the "delete role" to the template you want them to delete.
-
Soma's post in Get pages by datefield was marked as the answer
I don't think it's possible with a selector to recieve pages that have one specific month (across years). Your solution is the only I can think of.
However you could write an helper function to just be able to use $pages->findPeopleBorn(9); to keep template code thin. A module with a hook $this->addHook("Pages::findPeopleBorn",$this,"findPeopleBorn"); which then has a public method findPeopleBorn($event) that returns results would be a good way to do this. See "HelloWorld.module" for example.
One way to archive it without going through all users would be to separate day,month,year into their own fields. This would be easy to then query all pages with a specific month via a simple find(selector).
Or a custom mysql sql query to recieve the id's and load the pages from that. Assuming the date field is called "birthdate":
$tmplID = $templates->get("people")->id; $month = 8; $query = " SELECT field_birthdate.data,field_birthdate.pages_id FROM field_birthdate LEFT JOIN pages ON (field_birthdate.pages_id=pages.id) WHERE (EXTRACT(MONTH FROM field_birthdate.data) = $month) AND pages.status < 2048 AND pages.templates_id=$tmplID ORDER BY pages_id"; $res = $db->query($query); if($res->num_rows){ $ids = array(); while($u = $res->fetch_array()) $ids[] = $u['pages_id']; } $ids = implode("|",$ids); $people = $pages->find("id=$ids"); foreach($people as $p){ echo "<p>$p->title</p>"; } -
Soma's post in Why is "url" a reserved word? was marked as the answer
Maybe because ProcessWire uses url already? $page->url