Jump to content

Soma

Moderators
  • Posts

    6,798
  • Joined

  • Last visited

  • Days Won

    158

Everything posted by Soma

  1. Something you have on API side which is simple really. $p = $pages->get(1001); $p->of(true); // if in a template code, turn off output formatting $p->images->add("http://placehold.it/350x150.jpg"); $p->save(); $p->of(false); Everything is possible. With a simple module. As a basic start add a text or url field to the template near your "images" field, like a text field "add_images_url" Now with a autoload module (like site/modules/HelloWorld.module) you add a hook to when the field has url it will store it to the "images" field (or any on the page). All you need is to enter url and save page. <?php /** * AddImagesFromUrl * * On a page with fields * "add_images_url" text field * "images" images field * */ class AddImagesFromUrl extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'AddImagesFromUrl', 'version' => 101, 'summary' => 'Add images from url to images field', 'href' => 'http://www.processwire.com', 'singular' => true, 'autoload' => "template=admin", 'icon' => 'smile-o', ); } public function init() { $this->addHookAfter('Pages::saveReady', $this, 'addImage'); } public function addImage(HookEvent $event) { $page = $event->arguments("page"); if($page->template != "basic-page") return; if(!$page->add_images_url) return; // now interesting part, anything is possible here if(strpos($page->add_images_url, ".jpg") != false) { $page->images->add($page->add_images_url); $this->message("Added image from '$page->add_images_url' to images field"); $page->add_images_url = ''; } } } https://gist.github.com/somatonic/49f9e0a7faa8f6e6cfa3
  2. Why is there no error message? In the error log? Debug true turned on. Deinstalled custom modules one by one? PW Versions? etc...
  3. Works fine here. Nor sure, any custom modules messing with it?
  4. No there's no lang tabs for InputfieldPageListSelect.
  5. Role needs permission to do so.
  6. Note: new commit. 1.0.5 Hot bug fix for TinyMCE introduced in the last update.
  7. Done 2 years ago PW 2.2-3 and it's still working.
  8. MarkupSimpleNavigation FomSaveReminder PageEditSoftLock HelperFieldLinks ListerPro
  9. Or simply use MarkupSimpleNavigation module.
  10. RT @teppokoivula: 27th issue of ProcessWire Weekly is here – check it out! http://t.co/nViIk3OJH4 #cms #processwire

  11. Soma

    Grey Contrast

    Grey or gray?
  12. I'd guess your image field is multiple cause of the ->first() It, the field, should be name then header_images I think empty() isn't worth using here if( $page->header_images->count ){ $head_image = $page->header_images->first(); $img = $head_image->size(940,627); ... } else { // no image } If there were a issue with image field many would have this problem, but it's not.
  13. if(strpos($q, " ") !== false) $q = str_replace(" ", "|", $q); $result = $pages->find("template=basic-page, title|body%=$q");
  14. RT @JayUny: @somartist Someone has to pay you for your endless amounts of support and ambition that you put into the community.

  15. Somebody just sent me a microdonation on @flattr. Wow! Try Flattr out if you want to support me and other creators https://t.co/n3W4xB7EIf

  16. RT @martinmuzatko: I can't say how many years I have wasted with abusing #CMS to bend them to my needs. I could have embraced processwire e…

  17. get(selector) does a findOne(selector); findOne(selector) does a find(selector)->first(); $pages->get('parent=/blog/, sort=sort')
  18. I can't fill the email and phone field etc on my mobile. There's js going on that makes it impossibLe.
  19. Those would be LazyFields. In pirate voiceover.
  20. Ah. Well difficult one. All I know is that this is possible, but doesn't help and work in this case. $pages->find("template=basic-page, sort=-children.count"); After some thinking, the best (I think) way with stuff already there, would be to mabye store the conversations to a page field on the user. Then remove read conversations from the page field. If a message is created, the conversation/topic page will be added to all users page field once (the overhead has to go somewhere? And if done via direct sql to insert id's to page field it's fast even for thousands of users). // get the unread messages ids (1231|32232|2323|1233...) $unreadIDs = $user->unread_conversations; // OR groups either ids or parent $conversations = $pages->find("(id=$unreadIDs), (parent=/conversations_parent/), limit=3"); // output entries, ids unread should be on top? (can't test here) foreach($conversations as $conv){ $class_unread = $user->unread_conversations->has($conv) ? "unread" : "read"; echo "<p class='$class_unread'>$conv->title</p>"; } // render pager echo $res->renderPager();
  21. Or simply do a foreach foreach($notRead as $n) $conversations->prepend($n); I think regarding what you seem to be doing, you add a children page to a page with a reference to a user read the article? This may create performance problems and you already doing work to get it out list via a double searching/filtering. Not sure what would be a better way, since you seem to like the notread on top? So a sorting by it is difficult. Maybe some more thinking would reveal a more scalable/easier way to do this.. Anyway if the children grow and you do it the way you do it will create performance issue: This: (count($conversation->children("read_by!=$user")) Should be if($conversation->count("read_by!=$user")) ... Or this if($conversation->child("read_by!=$user"))
  22. This is done when you have a template with family setting to have allowed children template. On the children template select the parent template to allow, there will appear a setting to turn off or on if it should add it to the "Add New" button.
  23. Wouldn't this already possible with the WireCache? Store a cache with nameID and add a monitor module that when a page is changed or deleted looks for a cache of that name and deletes it?
  24. This is the current public function prepend($item) { parent::prepend($item); $this->numTotal++; return $this; } and should be maybe like this rather public function prepend($item) { parent::prepend($item); $this->numTotal = $this->count; return $this; } in PageArray.php
×
×
  • Create New...