Jump to content

Soma

Moderators
  • Posts

    6,808
  • Joined

  • Last visited

  • Days Won

    159

Everything posted by Soma

  1. https://processwire.com/talk/topic/3601-field-label-language-problem/
  2. What I do is use $config->js to populate the config array that I then output in the head for dynamic variables that want to share in a script. $config->js("myconfig", array("myajaxurl" => $pages->get(1991)->url); You can do this in templates or modules doesn't matter as long as it's before rendering page. Then this little to output as json. This is the same as PW uses in the admin to share config vars with js. <script type="text/javascript"> <?php // output javascript config json string to html // for use in javascripts from this point on $jsConfig = $config->js(); $jsConfig['debug'] = $config->debug; $jsConfig['urls'] = array( 'current_url' => $page->url, 'root' => $config->urls->root, ); ?> var config = <?php echo json_encode($jsConfig); ?>; </script> Then use in your script as var rootUrl = config.urls.root; for example
  3. You can also PW API since 2.4 or 2.5 echo $page->blog_tags->implode(", ", "title");
  4. kixie is right. Sorry, just to correct mine it would be index 2, because 1 is root parent and 0 would be root (home). $bar = $page->parents->eq(2); Just to summarize if called from the children // works $parent = $page->parent("parent=$page->rootParent"); // works and same as $parent = $page->parent("parent=1001"); // where 1001 would be /foo/ // works $parent = $page->parents->eq(2); $parent = $page->parents("parent=$page->rootParent")->first; // even works when on the parent itself $parent = $page->closest("parent=$page->rootParent");
  5. I use $p = $page->parents->eq(1);
  6. Issue seems with InputfieldCropImage.module rendering and testing if user is allowed to edit the current page, which is not there. It's not on context of a page edit. User profile doesn't have a "page" editing with an url param "id". Even if, the user isn't allowed to edit "user” page. ProcessProfile #67 fails $inputfield->value = $this->user->get($field->name); InputfieldCropImage.module in renderItem() fails and throws empty exception $page = $this->pages->get((int) $this->input->get->id); if(!$page->id || !$page->editable()) throw new WirePermissionException(); // empty
  7. I found by searching the forum for your image name "professionnel_photo" that it is a crop image (apeisa thumbnail) field. CropImage isn't compatible with user profile page editing. I tried adding a cropimage to user template and make it editable on the profile. It works fine but after trying to add an image I get same error as your's and can't edit profil anymore.
  8. From the error. Looks like you have a field dependency on a field using "role" field. First, "role" isn't a field but "roles". Second, roles aren't shown on when you view/edit your profile. It's not the same as editing a user.
  9. This would be just meant as an example! - Maybe this could lead to problems if you don't test for if the image is really an image before loading into the images field (local disk). Would need confirmation through if PW isn't already checking (?) - Copyrights? - Probably could need some check for allow_url_fopen (not sure either on this one) (Make it your own and modify)
  10. Edited: little buggers
  11. 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
  12. Why is there no error message? In the error log? Debug true turned on. Deinstalled custom modules one by one? PW Versions? etc...
  13. Works fine here. Nor sure, any custom modules messing with it?
  14. No there's no lang tabs for InputfieldPageListSelect.
  15. Role needs permission to do so.
  16. Note: new commit. 1.0.5 Hot bug fix for TinyMCE introduced in the last update.
  17. Done 2 years ago PW 2.2-3 and it's still working.
  18. MarkupSimpleNavigation FomSaveReminder PageEditSoftLock HelperFieldLinks ListerPro
  19. Or simply use MarkupSimpleNavigation module.
  20. RT @teppokoivula: 27th issue of ProcessWire Weekly is here – check it out! http://t.co/nViIk3OJH4 #cms #processwire

  21. Soma

    Grey Contrast

    Grey or gray?
  22. 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.
  23. if(strpos($q, " ") !== false) $q = str_replace(" ", "|", $q); $result = $pages->find("template=basic-page, title|body%=$q");
  24. RT @JayUny: @somartist Someone has to pay you for your endless amounts of support and ambition that you put into the community.

×
×
  • Create New...