Jump to content

Hari KT

Members
  • Posts

    126
  • Joined

  • Last visited

Posts posted by Hari KT

  1. Hi,

    From the processwire page tree listing, I am getting a strange error 

    SQLSTATE[HY000]: General error: could not call class constructor
    

    I am looking at http://blog.boringguys.com/2010/11/sqlstatehy000-general-error-could-not.html  when I noticed the same.

    I have added a few fields and upgraded to latest version of PW in dev branch.

    Any help to fix the page tree is appreciated.

    Thank you

  2. Hi Soma,

    I understood you need to pass all the fields that are required. If you miss a field, all the errors are thrown than throwing the missing one.

    I have also added a way to iterate through the fields and set the value on the Page.

    foreach ($form->getIterator() as $field) {
        $f = $field->name;
        $page->{$f} = $this->input->post->{$f};
    }
    

    Thanks!

  3. Hi Soma, 

    I was trying the code 

    $p = new Page();
    $p->template = "basic-page";
    $p->parent = 1;
    
    $in = new WireInputData();
    $in->setArray(array("title" => "Hello World"));
    
    $form = $modules->InputfieldForm;
    
    foreach($p->fields as $field){
        $inputfield = $field->getInputfield($p);
        $form->add($inputfield);
    }
    
    $form->protectCSRF = false;
    $form->processInput($in);
    
    foreach( $form->getErrors() as $err ) {
        $content .= $err;
    }
    

    but even if there is title it is showing title is empty on the errors. Do you know what may be the reason ?

    Thank you.

  4. Basically what I am doing is trying to build the form depending on the template .

    public function buildForm()
    {
            $form = $this->modules->get('InputfieldForm');
            $form->set('protectCSRF', false);
            $template = $this->templates->get($template);
            foreach ($template->fields as $field) {
    
                $f = $this->modules->get('InputfieldText');
                $f->name = $field->get('name');
                $f->required = $field->get('required');
                $form->add($f);
            }
            return $form;
    }
    

    So I could do a

    $form->processInput($this->input->post);

    One of the problem here is the field is always Text. Is there a better way to pass the field to the form, so the other properties can also be validated. Eg : Email, Url etc.

    Also even there is input with post values it is showing error, that the value is required in 

    $form->getErrorrs()

    Thank you.

  5. Hi, 

    I was looking whether I can validate the page before it is saved and get errors . Eg : 

    $page = new Page();
    $page->template = 'some-template';
    $page->field1 = 'some-value';
    $page->setOutputFormatting(true);
    $page->save();
    
    

    Assume there is 

    $page->field2

    which is also required. Is there a way I can validate and get the errors?

  6. @teppo My experience working with different open-source projects I have a feeling it would be nice to standardize things :-) .

    is framework interoperability (d'uh) much more than enabling something new in ProcessWire specifically

    Though it says is framework interoperability group, there are a few players like Drupal, EzPublizh and various other CMS / Frameworks there. Also do have a look at the cache PSR , the PSR-5 on docblocks are always nice.

  7. Hi all, 

    I would like to take your attention to a post "On HTTP, Middleware, and PSR-7" : https://mwop.net/blog/2015-01-08-on-http-middleware-and-psr-7.html .

    I believe that is a wonderful concept, so we could make use of other modules in the PHP ecosystem. I wish if anyone like the concept we could bring those into the 3.0 release ?

    Also there are bunch of other nice things like

    I also wish if someone could have a closer look on the things over fig, so things like this can be adopted.

    Your thoughts ?

    Thank you.

  8. Hi all,

    I was trying to add an image field to `implements Module, ConfigurableModule ` . When uploading image I was getting error as TemplateFile: Invalid image<pre>#0 [internal function]: InputfieldFile->___processInputAddFile('fdd-1.jpg') #1 

    public static function getModuleConfigInputfields(array $data) {
    
        $inputfields = new InputfieldWrapper();
        // $field = wire('modules')->get('InputfieldImage');
        // $field->attr('name', 'logo');
        // $field->label = __('Logo');
        // $field->addOption('logo', 'logo');
        // $field->attr('value', isset($data['logo']) ? $data['logo'] : '');
        $field = wire('modules')->get('InputfieldFile');
        $field->attr('name', 'logo');
        $field->label = __('Logo');
        $inputfields->add($field);
    
        return $inputfields;
    }
    

    I tried with file which gives me invalid extensions. Is there a way to fix it ?

    Basic idea is to extend a template which can have upload functionality of logo etc.

    Thank you.

  9. How many crops have you defined for that cropimage field in setup -> fields -> imagefield? I mean the total of all crops, regardless if you have bound some of them to specific templates. (can you drop the settings into your answer, that way I can see the dimensions too)
    thumbnail,75,75
    fullwidth,770,430
    halfwidth,360,200
    thirdwidth,240,180
    quarterwidth,180,160
     
    You have uploaded the 40 images without running into timeout, right? You only get a timeout later when trying to edit the page?

    Yes after the images being uploaded.

    UPDATE : 

    Do you have changed the settings for that field after you have uploaded the 40 images to your page?

    Yes. The thumb size have been changed. After that it caused it started the trouble.

    Can you enter the page edit with another role / account, not superuser? How does it behave? (same as superuser or does it have all imagevariations ready to display?)

     

    After removing a few images / changing the size of images the site is working as normal.

    Also the server have been upgraded so I doubt saying the same config , for both are different.

    Thank you.

  10. Hi @horst ,

    Thank you for the reply.

    The page have 3 text blocks, 5 image blocks, 1 video block, and 40 Images . Size of image varies from few 100 Kb to ~900 kb.

    Which kind of imagefield do you use, the core or the cropimage?

    CropImage

    How have you added the images to the field(s) / page(s), via API or via the Inputfield in backend and uploading?

    Input field in backend and uploading.

    How many images (in numbers) are "lots of images"?  50, 100, 500, 1000, ...?

    40

    Also, do you have one imagefield per page or multiple fields? If you have multiple fields, how many images are in total on a page?

    40

    It does not try to recreate images when viewing from the frontend, no? Only when in backend, opening a page for edit?

    On editing via the super admin the site is slower and getting error execution timeout.

    Do you (have) use(d) somewhere in your templates or elsewhere code that calls $pageimage->removeVariations()?

    No.

    Hope that helps

    Thanks!

  11. Hi Guys, 

    In 2.5 we can export the fields. I am wondering whether there is a way that it can handle importing the json from the modules when installing.

    Eg : A module is created which uses certain fields.

    I have exported the fields via export and keeping it at some fields.json .

    Does PW have the ability to find the fields.json and import the fields . This is just a question to know whether something like this have been added into core.

    Thank you

  12. Hi Guys,

    I have a trouble with building PageArray.

    Actually I am running the selector on a log when an article is read.

    The template=history , with article field links to article template .

    When a user reads an article I log to history the time article read. Think something similar to facebook history .

    Now I am trying to get the history back. So what I am doing is

    $articles_history = $pages->find("template=history, limit=3");
    $articles = new PageArray();
    $articles->setLimit($limit);
    $articles->setTotal($articles_history->getTotal());
    $start = ($input->pageNum - 1) * $limit;
    $articles->setStart($start);
    foreach ($articles_history as $article_history) {
       $articles->add($article_history->article);
    }
    
    $pagination = $articles->renderPager(array(
        'currentItemClass' => 'active',
        'listMarkup' => "<ul class='pagination'>{out}</ul>",
        'itemMarkup' => "<li class='{class}'>{out}</li>",
        'linkMarkup' => "<a href='{url}'><span>{out}</span></a>",
        'separatorItemLabel' => "<span>…</span>"
    ));
    echo $pagination;

    There are a few troubles though when the article is same. The PageArray will add only once, and no more duplicates are added. That is one trouble.

    Now the actual trouble is the correct pagination is not coming. I wonder whether it is due to this reason.

    There is only total 10 articles with 2 being duplicates. I added a limit of 3. Then the pagination on first shows me 1, 2, 3, 4, 5. Not sure why though.

    Is there a way to fix this ? If you have thought of using the $articles_history then I could not because the templates are required :-/ and being used by other places. Something like partials.

    Thank you

  13. Hi,

    I have add page field with categories to `user` template.

    In the processwire admin we can sort the page field items by dragging and moving the items.

    I would like to bring the same functionality to the front-end, so users can have a functionality to drag and drop. This can be saved via ajax rather than a save button.

    Would be helpful if anyone have done something like this.

    Thank you

×
×
  • Create New...