Jump to content

Zeka

Members
  • Posts

    1,065
  • Joined

  • Last visited

  • Days Won

    11

Everything posted by Zeka

  1. There is no built-in functionality. The simplest way is to create addtional fields like 'page_views' and 'page_popularity', then populate these fields inthe desirerable way and use them in your selectors like pages('template=post, sort=-page_views');
  2. Why just not create a text field like 'externa_id' and then check it while import like foreach ($import_records as $import_record) { $exists = $this->wire()->pages->has("template=some-template, external_id=" . $import_record['unique_id']); if($exists) { // update } else { // create a new page } }
  3. Hi @swissdoode . Take a look at Inputfields.js file, there are many methods that you could find helpfull https://github.com/processwire/processwire/blob/dev/wire/templates-admin/scripts/inputfields.js#L37
  4. Hi @toni. Process modules is intended to be used in admin and they are not autoloaded, so for such hook you can create an satelite autoload module or put this code to init.php file. class URLHooker extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'URLHooker', 'version' => '0.1', 'singular' => true, 'autoload' => true, 'requires' => [ 'YourProcessModule>=0.1' ], ); } public function init() { $this->wire()->addHook('/hello/world', function($event) { return 'Hello World'; }); } }
  5. Also take a look at ProcessHello module https://processwire.com/modules/process-hello/ https://processwire.com/blog/posts/pw-3.0.181-hello/ https://github.com/ryancramerdesign/ProcessHello
  6. https://github.com/processwire/processwire/blob/dev/wire/core/ProcessController.php#L388
  7. Hi @erikvanberkum It should return current langauge values without any additions to the code, so make sure that you made translations in field configuration.
  8. Hi. Is there a way to find pages by $page->meta data? Thanks.
  9. Hi @torf Have you tried to hook InputfieldPageAutocomple::findPagesSelector?
  10. @netcarver Have you tried using boot.php? In site/config.php $config->statusFiles = array( 'boot' => 'boot.php', 'init' => 'init.php', 'ready' => 'ready.php', 'finished' => 'finished.php' ); and in boot.php <?php namespace ProcessWire; wire('classLoader')->addNamespace('Wireframe\Blocks', paths('templates') . 'blocks/'); wire('classLoader')->addNamespace('Wireframe\Traits', paths('templates') . 'traits/'); I don't remember if I used traits in pages classes or in some other parts of the code, but you can try.
  11. @gregory Not sure that I got it. Do yo meen to output translated values? If so, AFAIC it should work without any aditions to the code and will output values for current user language, but if you want to output values in the specific langauge you can change user langauge before gettting options and then change it back to current langauge. $field = $fields->get('tipologia'); $currentLanguage = wire()->user->language; wire()->user->language = wire()->languages->get('another langauge name'); $all_options = $field->type->getOptions($field); wire()->user->language = $currentLanguage; $selected_option = $all_options->get("title="); // or ? foreach($all_options as $item) { $selected = $item->id === $selected_option->id ? " selected='selected' " : ''; echo "<option$selected value='{$item->id}'>{$item->title}</option>"; }
  12. Hi @gregory Something like this $field = $fields->get('tipologia'); $all_options = $field->type->getOptions($field); $selected_option = $all_options->get("title=" $input->item); // or id=some_id foreach($all_options as $item) { $selected = $item->id === $selected_option->id ? " selected='selected' " : ''; echo "<option$selected value='{$item->id}'>{$item->title}</option>"; }
  13. Hi @strandoo Probably, you can handle it by using owner selector. https://processwire.com/blog/posts/processwire-3.0.95-core-updates/ $speakers = $pages->find("template=speaker, speakers_field.owner.parent.parent.name=your-event-name"); Not tested, but should be someshing like this. It's always a bit difficult to grasp, but try to paly with it a little.
  14. Hi @lenoir Could you please clarify, are you speaking about ProcessPageList, ProcessPageSearch or Lister?
  15. Hi @kaz Hope, I got your message right if($page->matches('id=1233|3434')) {}
  16. @Ivan Gretsky Have you seen this config options? https://wireframe-framework.com/docs/configuration-settings/ Probably you could change partials path to 'templates' folder, than you will be able to use components views as partials.
  17. Hi @Ivan Gretsky Probably you can override render method of Type Component so it will render some partial. <?php namespace Wireframe\Blocks; use ProcessWire\Wireframe; class BlockTypeBlogTitle extends Block { protected function getDefaultViewData(): array { return [ 'title' => $this->item->get('title') ]; } public function ___render(): string { return Wireframe::partial('somepartial', $this->getDefaultViewData()); } } In this way you will be able to use same partial output both for components and partials.
  18. Hi @Ivan Gretsky That's how it works for me. In your case, you can create a controller for 'b' template that extends your 'a' template, call the parent init method and then set template for the view class PostsController extends CategoryController { public function init() { parent::init(); $this->view->setTemplate('category'); } }
  19. Hi @rick As error says, a page should be saved before adding to or accessing files from it. Take a look at this thread Probably you have to check for $page->isNew() and $page->id or just save a page before doing somting with files field like $uploadpage = new Page(); $uploadpage->template = "upload-entry"; $uploadpage->title = date("d-m-Y H:i:s") . " - " . uniqid(); $uploadpage->save(); //save page before adding files $uploadpage->images->add($upload_path . $file); // save uploaded files to new page $uploadpage->save(); I don't know the context of your code as the code itself, so it quite hard to say someting more.
  20. Hi @Krlos You can do it by hooking ProcessPageListRender::getPageLabel like here https://github.com/FlipZoomMedia/PageHitCounter/blob/master/PageHitCounter.module#L460 https://github.com/FlipZoomMedia/PageHitCounter/blob/master/PageHitCounter.module#L950
  21. $toJSON = $list->explode(function ($item) { return [ 'title' => $item->title, 'id' => $item->id, 'tags' => $item->tags->explode(function($subitem) use($item) { return [ 'id' => $subitem->id, 'title' => $subitem->title, 'parent_title' => $item->title, 'sub_page' => $subitem->page_field->explode(['id', 'title']) ] }) ]; }); You can get more info about explode, each and implode function here https://processwire.com/talk/topic/5098-new-wirearray-api-additions-on-dev/
  22. @ngrmm By the way, you can try to use $pages->findRaw https://processwire.com/api/ref/pages/find-raw/, like wireEncodeJSON($pages->findRaw('template=some-template, parent=1234,', ['id', 'title', 'tags' => ['id', 'title']);
  23. $list = $pages->get(1234)->children; $toJSON = $list->explode(function ($item) { return [ 'title' => $item->title, 'id' => $item->id, 'tags' => $item->tags->explode(['id', 'name', 'title']) ]; });
×
×
  • Create New...