-
Posts
131 -
Joined
-
Last visited
Posts posted by Hari KT
-
-
Hi,
I was trying to show the system template on Selectorfield as asked over : https://processwire.com/talk/topic/9026-show-system-templates-on-selectorfield/
Is there a way to make a hook like this work?
public function init() { $this->addHookBefore('InputfieldSelector::render', $this, 'selectorField'); } public function selectorField($event) { $inputSelector = $event->object; if ($event->object->name == 'field1') { $inputSelector->allowSystemTemplates = true; $event->return = $inputSelector; return $event->return; } }Though I did this, it seems not working properly
. -
Hi,Is there a way we can make the Selectorfield to choose system templates ?Currently I have created a Selectorfield and added to a template. Now when I create the page, the selector only shows the templates that are not system templates.I would like to show the system templates also in the list if possible.
-
Reverting back to the old version fixed it. I was trying to update with the latest dev branch.
-
Was going through the ajax request. Below is the error I have got
TemplateFile: SQLSTATE[HY000]: General error: could not call class constructor #0 /var/www/ProcessWire/wire/core/Pages.php(0): PDOStatement->fetchObject() #1 /var/www/ProcessWire/wire/core/Pages.php(229): Pages->getById(Array, Array) #2 [internal function]: Pages->___find('parent_id=1, st...', Array) #3 /var/www/ProcessWire/wire/core/Wire.php(365): call_user_func_array(Array, Array) #4 /var/www/ProcessWire/wire/core/Wire.php(320): Wire->runHooks('find', Array) #5 /var/www/ProcessWire/wire/core/PageTraversal.php(78): Wire->__call('find', Array) #6 /var/www/ProcessWire/wire/core/PageTraversal.php(78): Pages->find('parent_id=1, st...', Array) #7 /var/www/ProcessWire/wire/core/Page.php(1033): PageTraversal->children(Object(Page), 'start=0, limit=...', Array) #8 /var/www/ProcessWire/wire/modules/Process/ProcessPageList/ProcessPageList.module(178): Page->children('start=0, limit=...') #9 [internal function]: ProcessPageList->___find('start=0, limit=...', Object(Page)) #10 /var/www/ProcessWire/wire/core/Wire.php(365): call_user_func_array(Array, Array) #11 /var/www/ProcessWire/wire/core/Wire.php(320): Wire->runHooks('find', Array) #12 /var/www/ProcessWire/wire/modules/Process/ProcessPageList/ProcessPageList.module(165): Wire->__call('find', Array) #13 /var/www/ProcessWire/wire/modules/Process/ProcessPageList/ProcessPageList.module(165): ProcessPageList->find('start=0, limit=...', Object(Page)) #14 /var/www/ProcessWire/wire/modules/Process/ProcessPageList/ProcessPageList.module(109): ProcessPageList->render() #15 [internal function]: ProcessPageList->___execute() #16 /var/www/ProcessWire/wire/core/Wire.php(365): call_user_func_array(Array, Array) #17 /var/www/ProcessWire/wire/core/Wire.php(320): Wire->runHooks('execute', Array) #18 /var/www/ProcessWire/wire/core/ProcessController.php(213): Wire->__call('execute', Array) #19 /var/www/ProcessWire/wire/core/ProcessController.php(213): ProcessPageList->execute() #20 [internal function]: ProcessController->___execute() #21 /var/www/ProcessWire/wire/core/Wire.php(365): call_user_func_array(Array, Array) #22 /var/www/ProcessWire/wire/core/Wire.php(320): Wire->runHooks('execute', Array) #23 /var/www/ProcessWire/wire/core/admin.php(85): Wire->__call('execute', Array) #24 /var/www/ProcessWire/wire/core/admin.php(85): ProcessController->execute() #25 /var/www/ProcessWire/site/modules/AdminThemeThinktag/controller.php(13): require('/var/www/Proces...') #26 /var/www/ProcessWire/site/templates/admin.php(13): require('/var/www/Proces...') #27 /var/www/ProcessWire/wire/core/TemplateFile.php(169): require('/var/www/Proces...') #28 [internal function]: TemplateFile->___render() #29 /var/www/ProcessWire/wire/core/Wire.php(365): call_user_func_array(Array, Array) #30 /var/www/ProcessWire/wire/core/Wire.php(320): Wire->runHooks('render', Array) #31 /var/www/ProcessWire/wire/modules/PageRender.module(356): Wire->__call('render', Array) #32 /var/www/ProcessWire/wire/modules/PageRender.module(356): TemplateFile->render() #33 [internal function]: PageRender->___renderPage(Object(HookEvent)) #34 /var/www/ProcessWire/wire/core/Wire.php(365): call_user_func_array(Array, Array) #35 /var/www/ProcessWire/wire/core/Wire.php(320): Wire->runHooks('renderPage', Array) #36 /var/www/ProcessWire/wire/core/Wire.php(387): Wire->__call('renderPage', Array) #37 /var/www/ProcessWire/wire/core/Wire.php(387): PageRender->renderPage(Object(HookEvent)) #38 /var/www/ProcessWire/wire/core/Wire.php(320): Wire->runHooks('render', Array) #39 /var/www/ProcessWire/wire/modules/Process/ProcessPageView.module(172): Wire->__call('render', Array) #40 /var/www/ProcessWire/wire/modules/Process/ProcessPageView.module(172): Page->render() #41 [internal function]: ProcessPageView->___execute() #42 /var/www/ProcessWire/wire/core/Wire.php(365): call_user_func_array(Array, Array) #43 /var/www/ProcessWire/wire/core/Wire.php(320): Wire->runHooks('execute', Array) #44 /var/www/ProcessWire/index.php(195): Wire->__call('execute', Array) #45 /var/www/ProcessWire/index.php(195): ProcessPageView->execute() #46 {main} -
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
-
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!
-
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.
-
Hi Soma,
I am trying to build some REST sort api.
Thank you
-
Hi @Soma,
The above mentioned one is saving the page first. My idea is to validate the fields before I save the page.
-
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.
-
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?
-
@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.
-
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
- PSR-3 Logger Interface : http://www.php-fig.org/psr/psr-3/
- PSR-2 ( if we love to standardize the coding standard )
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.
-
> Ohhh, and you might be on a module settings config screen you are having this? There it won't work anyway as there's no page!
As Soma mentioned. It is for module configuration I was looking.
-
It was one of my dump mistake @SniNNuT . I missed to write `<script>` tags
.Thank you for reaching to help me.
-
Hi @Soma,
if I am adding a hook on a field and returning some html the values are escaped. Is there a way to turn off the escape functionality ?
-
@Soma got a few other tips from the code.
Thank you.
-
1
-
-
Yes @Soma,
I am from a Module configuration settings page .
-
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.
-
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,75fullwidth,770,430halfwidth,360,200thirdwidth,240,180quarterwidth,180,160You 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.
-
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!
-
I am wondering how does the cache works.
When logged in as admin, and trying to edit a page which have lots of images, PW thows an error `Imagesizer Maximum Execution Time` . The first one to see is https://processwire.com/talk/topic/7160-imagesizer-maximum-execution-time/ /
Wondering whether it is making use of the cache or it always loads even if the cache is there for the user is admin ?
Thank you.
-
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
-
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
Show system templates on Selectorfield
in General Support
Posted
Hi @Soma,
That seems you need to be on a page right ? I was mainly looking for an option to turn on / off from the field settings.