Jump to content

MichaMichaMicha

Members
  • Posts

    47
  • Joined

  • Last visited

Posts posted by MichaMichaMicha

  1. I have stored a lot of users with their birthdate. Now I'm trying to find the birthdays for the next 7 days but without succes.

    Already tried things like:

    template=user,birthdate$=02-26 but without success.

    It can be done with a raw MySQL-query, but I would like to prevent anything like that.
    One thing that I've thought of was imploding the current day for the last 100 years, (birthdate=2016-09-26|2015-09-26|2014-09-26,etc) but that would result in a 1100 chars long selector....  

     

    Anyone has an idea?

  2. I have a setup where users can enter some Hanna Code in the editor which will be replaced by a gallery that contains all images on that page or a chosen number of images.

    This is my Hannacode PHP

    <?php
    
    $images = $page->images; // name of your images field
    
    if ($images->count) {
    
    $config->scripts->add($config->urls->templates . "bower_components/fancybox/source/jquery.fancybox.pack.js");
    $config->styles->add($config->urls->templates . "bower_components/fancybox/source/jquery.fancybox.css");
    
    $showcount = ($show == "all") ? false : $show;
    $gallery = "<article class='gallery row'>";
    
    if($showcount) $images = $images->find("limit={$showcount}");
    
        foreach ($images as $i) {
            $thumb = $i->size(300, 300);
            
            $desc = ($i->description) ? $i->description : $page->title;
            
            $gallery .= "<div class='col-md-4'>
            <div class='thumbnail'>
            <a class='fancybox' rel='group' href='{$i->url}'>
            <img src='{$thumb->url}' alt='{$desc}'>
            </a>
            <p class='caption'>{$desc}</p>
            </div>
            </div>";
    
        }
    
    }
    
    $gallery .= "</article>";
    
    echo $gallery;
    
    

    Hanna Code to insert into the editor:

    [[gallery]] // shows all images
    [[gallery show=6]] // shows first 6 images
    
    

    Settings in Hanna Code module

    attachicon.gifhannacode-settings1.png

    With this solution users cannot choose the images for the gallery from within CKEditor but it takes images from the images field of that page.

    This should get you started. Obviously you'd need to adjust script paths and markup (I'm using Bootstrap 3 here)

    Thanks.

    However I would like the editor to achieve something like:

    <p>Lorem</p>
    
    <div class='gallery'>
    <img src='1.jpg' />
    <img src='2.jpg' />
    <img src='3.jpg' />
    </div>
    
    <p>Lorem ipsum</p>
    
    <div class='gallery'>
    <img src='4.jpg' />
    <img src='5.jpg' />
    <img src='6.jpg' />
    </div>
    <p>Lorem ipsum dolor sit</p>
    

    Also I would like to prevent the editor to make use of hannacode because it's not that user friendly.

    Anyone got another suggestion?

  3. I have a content field (CKeditor) where I want the editor to be able to insert galleries with photo's anywhere in the content. Like the image insert functionality already present but with the option to add multiple images and have them transform into a gallery using Javascript. The javascript is not an issue but I'm not sure how to get the images nicely in the CKeditor field.

    I kind of like the solution Wordpress has for galleries...  :undecided:

    Any module like that available for Processwire?

  4. Thanks for that MichaMichaMicha,

    At first I was excited about the article...people have been waiting for this....Then reading it, it turns out (not-so-under the hood) this is an article about WordPress! What cheek! Underneath all the veneer about talking about PW, he/she is just bashing PW and not really saying much about its strength. Nothing about its raw power! I don't think the writer has even used PW before!! What a load of tosh! My frustration is not vented at you....but the writer of the article... That was supposed to be an intro...for crying out loud!  >:(

    Agreed, but I guess PW has never had this many tweets about it as in the last two hours:

    https://twitter.com/search?f=tweets&vertical=default&q=processwire

    any publicity is good publicity

    • Like 1
  5. @MichaMichaMicha

    Reading your question again, I think I didn't fully understand it before ;) You can grab the actual page with

    $page = wire('page');
    

    Hmm, sorry. That doesn't work. This still returns the User. To be clear:

    I'm echoing $someUser->url on a 'normal' page/template. I want the hook to return the url from the 'normal' page appended with the name field for the user. I'm using urlSegments on the 'normal' template to receive the users name.

    There are multiple 'normal' pages that can have the same user as a urlSegment (having them in a Page selecting field on the 'normal' template)

    These are the some example values that I would like to return in the hook.

    /just-a-page/john-doe/ (when the calling Page is "just-a-page")
    /just-a-page/jane-doe/ (when the calling Page is "just-a-page")
    /another-page/jane-doe/ (when the calling Page is "another-page")
    /yet-another-page/lorem-subpage/john-doe/ (when the calling Page is "yet-another-page/lorem-subpage/")
    

    Of course I could just use this in my 'normal' template:

    echo $page->url.$theUser->name;
    

    but I'm always trying to learn, so would like to use the Hook :)

  6. I'm trying to modify the property 'path' for a specific Page (User, actually) using the following code: 

    $this->addHookAfter("Page::path",$this,"modifyUserPagePath");
    
    AND
    
    public function modifyUserPagePath(HookEvent $event){
    
    	$p = $event->object;
    
    	if($p->template == "user" && $p->hasRole("ambassador")){
    
    		die("MODIFY THE PATH HERE WITH PREFIX FOR THE CURRENT VIEWING PAGE");
    	}
    
    }
    

    But i'm not able to retrieve the page that is currently running (as in, the page in the browser url).

    Please note I'm also using the render() method to render subpages content. I don't need the subpages url but only the original $page requested.

    Is there a pretty way to do this (besides looking it up via $_SERVER['REQUEST_URI'] )?

  7. Pretty old topic, maybe you figured it out already, but:

    You always need a wrapping class row when you use columns.

    You code should be:

    <div class='row'>
       <div class='medium-3 columns'>
          <div class='row'>
             <div class='small-12 columns'>content</div>
             <div class='small-12 columns'>content</div>
             <div class='small-12 columns'>content</div>
          </div>
       </div>
    </div>
    
    • Like 1
  8. Finally got a workaround for this.

    Simply added 

    $this->pages->uncache($repeaterParent); 

    after

    https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/modules/Fieldtype/FieldtypeRepeater/FieldtypeRepeater.module#L556

    When debugging is on in config.php you see the message twice:

    Session: Created Repeater Page Parent: /admin/repeaters/for-field-140/for-page-24397/

    Not the prettiest solution but at least the client can add pages again.

  9. I've stumbled upon a weird issue with repeaters.

    I've created a repeaterfield with only a title field and assigned it to a template.

    When I create the first page everything goes well, but then when I'm creating additional pages I'm getting this error:

    ProcessPageAdd: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'for-page-23947-23799' for key 'name_parent_id'

    I'm not getting redirected (probably because of the error, but the page does get created with the RepeaterField correctly).

    The problem seems to exist in the file FieldtypeRepeater.module in the function 'getRepeaterPageParent'.

    I've modified the file to see what actually happens and it looks like the function doesn't find the required page of saves the page correctly.

    protected function getRepeaterPageParent(Page $page, Field $field) { 
    
    		$repeaterParent = $this->getRepeaterParent($field);
    		
    
    		
    		$parent = $repeaterParent->child('name=' . self::repeaterPageNamePrefix . $page->id . ', include=all'); 
    		$this->message("L".__LINE__." | selectorresult: ".$parent->id);
    		
    		if($parent->id) return $parent; 
    
    
    		$parent = new Page();
    		$parent->template = $repeaterParent->template;
    
    		$this->message("L".__LINE__." | template: ".$repeaterParent->template);
    		$this->message("L".__LINE__." | parent: ".$repeaterParent->path);
    		$parent->parent = $repeaterParent->id; 
    		$parent->name = self::repeaterPageNamePrefix . $page->id;
    		$parent->title = $page->name;
    		$parent->addStatus(Page::statusSystem);
    
    		// exit early if a field is in the process of being deleted
    		// so that a repeater page parent doesn't get automatically re-created
    		if($this->deletePageField === $field->parent_id){
    			return $parent; 
    		}
    
    		$parent->save();
    		
    		$this->message("L".__LINE__." | looking for: ".self::repeaterPageNamePrefix . $page->id);
    		$this->message("L".__LINE__." | current for: ".$parent->name);
    		$this->message("L".__LINE__." | Created Repeater Page Parent: NAME={$parent->name} a " . $parent->path, Notice::debug); 
    
    		return $parent; 
    	}
    
    

    See the attachment for the output. IMO the second time FieldtypeRepeater: L574 |  should output the previously created page...

    Anyone has an idea what's going wrong? I'm on the latest master branch.

    post-943-0-89910200-1403594816_thumb.png

  10. I've really tried my best but seems like I'm not able to change a fields description text in context of a template via the api.

    $template->fieldgroup->title->description = "This should be the description";
    $template->fieldgroup->title->save();
    $template->fieldgroup->save();
    

    Anybody having the same problem?

    Note: if that works I also want to change the description in different languages, but that should not be a problem.

  11. You want to hook into this method:

    	public function ___executeList() {
    		return $this->renderList("limit=25, status<" . Page::statusMax);
    	}
    

    It's defined in the superclass, ProcessPageType.

    As the renderList method itself is not hookable, you'd need to generate your own markup which is returned from executeList()

    Great, that worked. Thanks!

  12. I've a site with different sections. Each user is assigned to a section and each section has an editor.

    I want those editors to be able to modify the users that are assigned to their section.

    I tried hooking into ProcessUser::execute but I'm not sure how to filter the 'pages'.

    $this->addHookBefore('ProcessUser::execute', $this, 'modifyuserpagelist'); 
    

    In what way am I able to modify the User List?

  13. First the structure (offtopic, Structure reminds me of EE :(  )

    Home
    -Company Page
    --Section (template: container)
    ---Child page 1 (template: content)
    ---Child page 2 (template: content)
    ---etc. 

    I have editors that can add pages to template container, but not edit the page.

    Problem is that they can not sort the child pages (template:content) by default.

    Solved it by adding a 'move-children' role that has move-pages and sort-pages permissions.

    The problem lies in setting that role and permissions to the template 'container'. You cannot select the 'Create Pages' checkbox for role 'move-children' unless you also give the 'move-children' role the 'edit-page' permission. (It's disabled) (I'm not sure if I'm using the correct terms...)

    Eventually I solved it by setting the 'edit-pages' permission to the 'move-children' role, checking all the boxes for the template access, and then removing the 'edit-pages' permission.

    I don't know if this is the intented behaviour but I thought I'd share it with you to see what you've experienced.

    Thanks

    • Like 1
  14. Hi,

    I am wondering if the issue on IE has been fixed? I am using IE8 and the page is not styled at all, not sure if the issue has been addressed :) Thanks

    Hi Peter,

    I tested the minifier on two sites using IE8, but both of them were showing the styles. I used Unsemantic Site Profile for Processwire and the default PW Profile.

    My IE8 version is 8.0.6001.18702

    If you've got a minute to spare, can you check the default PW profile with the minifer using your version of IE8. What version do you use?

    If anyone else already knows what's wrong, please let me know.

    Thanks.

  15. I've now twice noticed a problem after I deployed a version to a live server.

    For example the top buttons in Admin.

    Usually they are in the order:

    • Pages
    • Setup
    • Modules
    • Access

    Only when I pushed everyting (incl database export) live the order seems to have changed to 

    • Pages
    • Modules
    • Setup
    • Access

    I also noticed a simple selector seems to ignore the sort I used, and used I think the ID for sorting.

    It was a critical moment so I quick-hacked a sort after the selector got it results, and thus was not able to get the source ot the problem.

    The production server uses CentOS with Php 5.2.17 and MySQL 5.0.51a

    Before I lose hours in debugging and testing, maybe anyone has noticed the same issues and already figured out what was wrong?

  16. That's fun:

    foreach($templates as $template){
        foreach($template->fieldgroup as $field){
            if($field->name == "myfield"){
                $template->fieldgroup->remove($field);
                $template->fieldgroup->save();
                echo "deleted $field->name";
            }
        }
    }
    

    I was looking for some something in the Admin, but this works as well... Thanks!

×
×
  • Create New...