Search the Community
Showing results for tags 'API'.
-
Is there a way to make JPGs progressive by default via the API? I've added the following to my site/config.php file but user-uploaded images are often displayed as non progressive. $config->imageSizerOptions = array( 'upscaling' => true, // upscale if necessary to reach target size? 'cropping' => true, // crop if necessary to reach target size? 'autoRotation' => true, // automatically correct orientation? 'interlace' => true, // use interlaced JPEGs by default? (recommended) 'sharpening' => 'soft', // sharpening: none | soft | medium | strong 'quality' => 95, // quality: 1-100 where higher is better but bigger 'hidpiQuality' => 60, // Same as above quality setting, but specific to hidpi images 'defaultGamma' => 0.5, // defaultGamma: 0.5 to 4.0 or -1 to disable gamma correction (default=2.0) ); Thanks
- 12 replies
-
- progressive
- interlaced
-
(and 4 more)
Tagged with:
-
Hey everyone, I am trying to assign a page with template term-translation to variable $terms using the code below. This page is filled with fields that I use to translate certain texts. <?php namespace ProcessWire; $terms = $pages->find('template=term-translation'); This snippet is at the start of code in a .module file (specifically LoginRegister). The problem is that the $pages is null, or atleast that is what the error is telling me. Error: Exception: Call to a member function find() on null. I use this code in .php template files of my website and they work as they should. Does anyone have a solution to this problem. If this topic was already in here somewhere, then I am sorry, but I could not find it. Thanks for your help.
-
Navigation Function get the root page with wire()
congomonster_616 posted a topic in API & Templates
Hi, after a long time i use processwire again. But i have a problem and can't get a solution. I have build a navigation. I have to reuse this part. So i thought, i could write a function. I have searched the forum and i learned that i have to use wire() to get access to the sites inside the function. My problem is now, that everytime i click on a new site (children of home), the menu only shows the current page and there children. I know, that's what i have coded. ? Without the function i could use $home to get the root site and the children. How can i acess always the root page in the function? And display all the sites? I tried to get wire("pages") instead, but i don't know how tu use the object. I would be really thankful if someone shows me the right direction. <?php namespace ProcessWire; function navigation() { $page = wire("page"); echo "<ul class='navbar-nav my-3 my-lg-0 fw-semibold rounded'>"; foreach ($page->and($page->children()) as $item) { // set the active class $active_link=""; if ($page->id == $item->id) { $active_link="nav-link active p-3"; } else { $active_link="nav-link p-3"; } echo "<li class='nav-item'><a href='". $item->url ."' class='" . $active_link . "'>" . $item->title . "</a><li>"; } echo "</ul>"; } ?>- 2 replies
-
- wire()
- navigation
-
(and 1 more)
Tagged with:
-
I am about to create several pages via API. In another script I populate the fields per language. I found that each page generated via API, even when alternative languages are also populate, they are inactive by default. Is there an API method to set it to active? Either when creating a page, or when updating it (setting field values). (PW 2.3.2 setup)
- 11 replies
-
- 1
-
Hello, I´m trying to make a REST API with PW. is there something like $wire('input')->get and $wire('input')->post but for the verbs delete and put? also how can I separate the code for each verb. example: I have the following endpoint /users/emails Processwire can detect what verb is beign used to call that endpoint? (automatically call the corresponding code paired with the verb) or I have to manually check it and execute the corresponding code, using an if or something similar. basically I am looking for a router like Lime https://github.com/aheinze/Lime If PW does not have a router, using wire('pages') inside Lime it´s possible without conflicts? Thanks.
-
Hi all, Just wondering if anyone else has encountered this issue. During some work recently I have noticed that it seems like when you use count() on a repeating field to determine if theres any content to output, it works fine on a template but behind the scenes as part of a module it doesn't return the same results on the same data set. For instance. On the frontend template this outputs as you would imagine: Doing a count on that same field, from within a module I get count() returning as 2, which makes sense as both are enabled. However I noticed that, if I then disable one of the repeating items, ala: This is reflected in the frontend as you would imagine, like so: However within the module logic, the value of count() on the same data set will still return as 2 The fact that I can't rely on the count within the module being correct is having major knock on effects as I have no idea whether to trust any information brought back about that repeating field. Does anyone know a way to get a correct number from a repeating_field->count or count(repeating_field) from the API, that actually takes into account the enable/disabled status of the elements within it? I have tried using various methods which are fine on a page template but just seem unreliable in my modules context, for some clarity, this is how I am pulling out the same field via the module: $overrides = $this->pages->findOne("template=plot, parent.id="666", title=plot 101"); then the following to check if there any content within the repeater error_log('COUNT:'.count($overrides->key_features)); For the record the following also appears to be giving the same as above error_log('COUNT:'.$overrides->key_features->count); So presumably this is a bug or COUNT() works diffferently between use in templates and usage with the API? If its working as intended, can anyone point me towards some documentation that explains the differences? Any thoughts would be much appreciated?
-
Hey all. I am trying to create an image-field from API. It is working fine, but opening the page with the new image-field leads to the following error: FieldtypeImage: Field "servicetype_image_1129" is not yet ready to use and needs to be configured. For all other fields I am creating in this module (e.g. checkbox, textarea)...everything is working without errors. This is my code to create the image-field: $f_img = new Field(); $f_img->type = $this->modules->get("FieldtypeImage"); $f_img->name = 'servicetype_image_' . $page->id; $f_img->label = $page->get('title')->getDefaultValue() . ' Service-Type Image'; $f_img->set('tags',$tag); $f_img->set('icon',$icon); $f_img->set('maxFiles', '1'); $f_img->set('noLang', 1); $f_img->set('adminThumbs', 1); $f_img->set("textformatters", array("TextformatterEntities")); $f_img->save(); Anybody an idea what is causing the problem? Thanks a lot in advance!!
-
Hi all, Just a little context, I have need of a select/drop down on a form to update automatically. So I believed I had achieved this, by programmatically updating said field via an webhook, code included below. Which looked like it worked, as all the correct options do now infact show in the drop down on page load.... However, whenever I select one of these newly added options on the drop down and hit submit, it always throws an error as if the field has infact been left blank? Out of curiosity I removed the 'Required' settings from the field, which when I tested does allow me to select a development and then submit without the error, however if you then check the entries tab within Formbuilder that field is just left blank? I also removed the webhook for dynamic population wherein the field on the form started behaving normally again, so presumably something below is causing the problem? Any ideas? $wire->addHookBefore('InputfieldSelect::render', function($event) { $inputfield = $event->object; if($inputfield->name != 'priority_development') return; $options = $inputfield->options; // Get the existing options //GET CURRENT PUBLISHED DEVELOPMENTS $options_new = []; $pages = Processwire\wire('pages')->find('template=development'); foreach($pages as $page){ $region = $page->development_region->title; $options_new[$page->id] = $region.', '.$page->title; } asort($options_new); $inputfield->options = []; // Remove all the existing options // Add the options back with attributes $inc = 0; foreach($options_new as $value => $label) { // Set whatever attributes you want as $key => $value in the last argument of addOption() if($inc == 0) { $inputfield->addOption($value, $label, array('selected' => 'selected')); } else { $inputfield->addOption($value, $label); } $inc++; } $event->return = $inputfield; });
- 1 reply
-
- formbuilder
- api
- (and 4 more)
-
Page Query Boss Build complex nested queries containing multiple fields and pages and return an array or JSON. This is useful to fetch data for SPA and PWA. You can use the Module to transform a ProcessWire Page or PageArray – even RepeaterMatrixPageArrays – into an array or JSON. Queries can be nested and contain closures as callback functions. Some field-types are transformed automatically, like Pageimages or MapMarker. Installation Via ProcessWire Backend It is recommended to install the Module via the ProcessWire admin "Modules" > "Site" > "Add New" > "Add Module from Directory" using the PageQueryBoss class name. Manually Download the files from Github or the ProcessWire repository: https://modules.processwire.com/modules/page-query-builder/ Copy all of the files for this module into /site/modules/PageQueryBoss/ Go to “Modules > Refresh” in your admin, and then click “install” for the this module. Module Methods There are two main methods: Return query as JSON $page->pageQueryJson($query); Return query as Array $page->pageQueryArray($query); Building the query The query can contain key and value pairs, or only keys. It can be nested and contain closures for dynamic values. To illustrate a short example: // simple query: $query = [ 'height', 'floors', ]; $pages->find('template=skyscraper')->pageQueryJson($query); Queries can be nested, contain page names, template names or contain functions and ProcessWire selectors: // simple query: $query = [ 'height', 'floors', 'images', // < some fileds contain default sub-queries to return data 'files' => [ // but you can also overrdide these defaults: 'filename' 'ext', 'url', ], // Assuming there are child pages with the architec template, or a // field name with a page relation to architects 'architect' => [ // sub-query 'name', 'email' ], // queries can contain closure functions that return dynamic content 'querytime' => function($parent){ return "Query for $parent->title was built ".time(); } ]; $pages->find('template=skyscraper')->pageQueryJson($query); Keys: A single fieldname; height or floors or architects The Module can handle the following fields: Strings, Dates, Integer… any default one-dimensional value Page references Pageimages Pagefiles PageArray MapMarker FieldtypeFunctional A template name; skyscraper or city Name of a child page (page.child.name=pagename); my-page-name A ProcessWire selector; template=building, floors>=25 A new name for the returned index passed by a # delimiter: // the field skyscraper will be renamed to "building": $query = ["skyscraper`#building`"] Key value pars: Any of the keys above (1-5) with an new nested sub-query array: $query = [ 'skyscraper' => [ 'height', 'floors' ], 'architect' => [ 'title', 'email' ], ] A named key and a closure function to process and return a query. The closure gets the parent object as argument: $query = [ 'architecs' => function($parent) { $architects = $parent->find('template=architect'); return $architects->arrayQuery(['name', 'email']); // or return $architects->explode('name, email'); } ] Real life example: $query = [ 'title', 'subtitle', // naming the key invitation 'template=Invitation, limit=1#invitation' => [ 'title', 'subtitle', 'body', ], // returns global speakers and local ones... 'speakers' => function($page){ $speakers = $page->speaker_relation; $speakers = $speakers->prepend(wire('pages')->find('template=Speaker, global=1, sort=-id')); // build a query of the speakers with return $speakers->arrayQuery([ 'title#name', // rename title field to name 'subtitle#ministry', // rename subtitle field to ministry 'links' => [ 'linklabel#label', // rename linklabel field to minlabelistry 'link' ], ]); }, 'Program' => [ // Child Pages with template=Program 'title', 'summary', 'start' => function($parent){ // calculate the startdate from timetables return $parent->children->first->date; }, 'end' => function($parent){ // calculate the endate from timetables return $parent->children->last->date; }, 'Timetable' => [ 'date', // date 'timetable#entry'=> [ 'time#start', // time 'time_until#end', // time 'subtitle#description', // entry title ], ], ], // ProcessWire selector, selecting children > name result "location" 'template=Location, limit=1#location' => [ 'title#city', // summary title field to city 'body', 'country', 'venue', 'summary#address', // rename summary field to address 'link#tickets', // rename ticket link 'map', // Mapmarker field, automatically transformed 'images', 'infos#categories' => [ // repeater matrix! > rename to categories 'title#name', // rename title field to name 'entries' => [ // nested repeater matrix! 'title', 'body' ] ], ], ]; if ($input->urlSegment1 === 'json') { header('Content-type: application/json'); echo $page->pageQueryJson($query); exit(); } Module default settings The modules settings are public. They can be directly modified, for example: $modules->get('PageQueryBoss')->debug = true; $modules->get('PageQueryBoss')->defaults = []; // reset all defaults Default queries for fields: Some field-types or templates come with default selectors, like Pageimages etc. These are the default queries: // Access and modify default queries: $modules->get('PageQueryBoss')->defaults['queries'] … public $defaults = [ 'queries' => [ 'Pageimages' => [ 'basename', 'url', 'httpUrl', 'description', 'ext', 'focus', ], 'Pagefiles' => [ 'basename', 'url', 'httpUrl', 'description', 'ext', 'filesize', 'filesizeStr', 'hash', ], 'MapMarker' => [ 'lat', 'lng', 'zoom', 'address', ], 'User' => [ 'name', 'email', ], ], ]; These defaults will only be used if there is no nested sub-query for the respective type. If you query a field with complex data and do not provide a sub-query, it will be transformed accordingly: $page->pageQueryArry(['images']); // returns something like this 'images' => [ 'basename', 'url', 'httpUrl', 'description', 'ext', 'focus'=> [ 'top', 'left', 'zoom', 'default', 'str', ] ]; You can always provide your own sub-query, so the defaults will not be used: $page->pageQueryArry([ 'images' => [ 'filename', 'description' ], ]); Overriding default queries: You can also override the defaults, for example $modules->get('PageQueryBoss')->defaults['queries']['Pageimages'] = [ 'basename', 'url', 'description', ]; Index of nested elements The index for nested elements can be adjusted. This is also done with defaults. There are 3 possibilities: Nested by name (default) Nested by ID Nested by numerical index Named index (default): This is the default setting. If you have a field that contains sub-items, the name will be the key in the results: // example $pagesByName = [ 'page-1-name' => [ 'title' => "Page one title", 'name' => 'page-1-name', ], 'page-2-name' => [ 'title' => "Page two title", 'name' => 'page-2-name', ] ] ID based index: If an object is listed in $defaults['index-id'] the id will be the key in the results. Currently, no items are listed as defaults for id-based index: // Set pages to get ID based index: $modules->get('PageQueryBoss')->defaults['index-id']['Page']; // Example return array: $pagesById = [ 123 => [ 'title' => "Page one title", 'name' => 123, ], 124 => [ 'title' => "Page two title", 'name' => 124, ] ] Number based index By default, a couple of fields are transformed automatically to contain numbered indexes: // objects or template names that should use numerical indexes for children instead of names $defaults['index-n'] => [ 'Pageimage', 'Pagefile', 'RepeaterMatrixPage', ]; // example $images = [ 0 => [ 'filename' => "image1.jpg", ], 1 => [ 'filename' => "image2.jpg", ] ] Tipp: When you remove the key 'Pageimage' from $defaults['index-n'], the index will again be name-based. Help-fill closures & tipps: These are few helpfill closure functions you might want to use or could help as a starting point for your own (let me know if you have your own): Get an overview of languages: $query = ['languages' => function($page){ $ar = []; $l=0; foreach (wire('languages') as $language) { // build the json url with segment 1 $ar[$l]['url']= $page->localHttpUrl($language).wire('input')->urlSegment1; $ar[$l]['name'] = $language->name == 'default' ? 'en' : $language->name; $ar[$l]['title'] = $language->getLanguageValue($language, 'title'); $ar[$l]['active'] = $language->id == wire('user')->language->id; $l++; } return $ar; }]; Get county info from ContinentsAndCountries Module Using the [ContinentsAndCountries Module](https://modules.processwire.com/modules/continents-and-countries/) you can extract iso code and names for countries: $query = ['country' => function($page){ $c = wire('modules')->get('ContinentsAndCountries')->findBy('countries', array('name', 'iso', 'code'),['code' =>$page->country]); return count($c) ? (array) $c[count($c)-1] : null; }]; Custom strings from a RepeaterTable for interface Using a RepeaterMatrix you can create template string for your frontend. This is usefull for buttons, labels etc. The following code uses a repeater with the name `strings` has a `key` and a `body` field, the returned array contains the `key` field as, you guess, keys and the `body` field as values: // build custom translations $query = ['strings' => function($page){ return array_column($page->get('strings')->each(['key', 'body']), 'body', 'key'); }]; Multilanguage with default language fallback Using the following setup you can handle multilanguage and return your default language if the requested language does not exist. The url is composed like so: `page/path/{language}/{content-type}` for example: `api/icf/zurich/conference/2019/de/json` // get contenttype and language (or default language if not exists) $lang = wire('languages')->get($input->urlSegment1); if(!$lang instanceof Nullpage){ $user->language = $lang; } else { $lang = $user->language; } // contenttype segment 2 or 1 if language not present $contenttype = $input->urlSegment2 ? $input->urlSegment2 : $input->urlSegment1; if ($contenttype === 'json') { header('Content-type: application/json'); echo $page->pageQueryJson($query); exit(); } Debug The module respects wire('config')->debug. It integrates with TracyDebug. You can override it like so: // turns on debug output no mather what: $modules->get('PageQueryBoss')->debug = true; Todos Make defaults configurable via Backend. How could that be done in style with the default queries? Module in alpha Stage: Subject to change This module is in alpha stage … Query behaviour (especially selecting child-templates, renaming, naming etc) could change
- 24 replies
-
- 29
-
Hello forum, This is really a weird one, because front end editing works in a earlier website we did to a customer. When I check the source code for current website it does initiate front end edit: <span id=pw-edit-1 class='pw-edit pw-edit-InputfieldPageTitle' data-name=title data-page=1021 data-lang='1017' style='position:relative'><span class=pw-edit-orig>Tekijät</span><span class=pw-edit-copy id=pw-editor-title-1021 style='display:none;-webkit-user-select:text;user- select:text;' contenteditable>Tekijät</span></span> But when I double click nothing happens (yes I'm 100% sure I'm superuser and logged in) I also tried to apply the front end with other methods than: $page->edit('title'); But didn't work either. We are using jquery 2.2.4, so it should not be a problem. Is this a bug related to current master or something else? Someone else having this problem as well?
- 3 replies
-
- front end editing
- api
-
(and 2 more)
Tagged with:
-
Hello forum, this is my first security related post, so I'm a bit of a newbie. I understand that when I have direct front-input from user I should sanitize the input, but how about when I use a secret key for showing a API for a third-party supplier? Should I sanitize the input->get() key? I've tested this issue and I tried ?key=<?php echo $page->field; ?> And without adding any sanitization it comes back: /?key=<?php%20echo%20$page->field;%20?> So can I rely on this, or should I still use $sanitizer just in case? Thanks for the help!
- 4 replies
-
- security
- injections
-
(and 2 more)
Tagged with:
-
Hello There, I have saw a post that was covering event-calendar with php, ajax and js. That was showing a monthly overview when I click on a "month" button or when I switch the month. And show the events on one particular date when I pick a day. Also, most events are kind of exhibitions and so they have a start date and an end date much later, and occur on each day in-between as well. So on the template I put two date picking fileds date_start and date_end. Is there an elegant way to select the events using the API? If yes, kindly help me out. Thanks in Advance Regards:
-
wireshell 1.0.0 is out See Bea's post -------- Original post ----------- Now this one could be a rather long post about only an experimental niche tool, but maybe a helpful one for some, so stay with me Intention Do you guys know "Artisan" (Laravel) or "Drush" (Drupal)? If not: These are command line companions for said systems, and very useful for running certain (e.g. maintenance, installation) task quickly - without having to use the Admin Interface, first and foremost when dealing with local ProcessWire installations. And since it has a powerful API and an easy way of being bootstrapped into CLIs like this, I think such a tool has a certain potential in the PW universe. It's totally not the first approach of this kind. But: this one should be easily extendable - and is based on PHP (specifically: the Console component of the Symfony Framework). Every command is tidily wrapped in its own class, dependencies are clearly visible, and so on. ( Here was the outdated documentation. Please visit wireshell.pw for the current one )
- 176 replies
-
- 33
-
I'm trying to create a pagename (for internal use, not for presentation to the users) with multiple dashes in the middle. Here's an excerpt of my code: $p = new Page(); $p->template = 'template-name'; $p->name = "$prod--$variation"; ProcessWire seems to apply $sanitizer->pageName($name, true) which converts multiple dashes to a single dash so the page name doesn't have "--" in it. How can I force it to have multiple dashes?
-
I am working on my first Process Module. I am creating forms. Fairly straightforward. However, I really can't work out how to create multiple fieldsets? $fieldset = $this->modules->get('InputfieldFieldset'); $fieldset->label = 'Customer Source'; $field = $this->modules->get('InputfieldPage'); $field->inputfield = 'InputfieldSelect'; $field->findPagesSelector = 'parent_id=1449, include=hidden'; $field->labelFieldName = 'yff-lead'; $field->name = 'yfflead'; $field->columnWidth = 16; $fieldset->add($field); $field = $this->modules->get('InputfieldPage'); $field->inputfield = 'InputfieldSelect'; $field->findPagesSelector = 'parent_id=1452, include=hidden'; $field->labelFieldName = 'customer-type'; $field->name = 'customertype'; $field->columnWidth = 16; $fieldset->add($field); //Rinse and Repeat $fieldset->label = 'Contacts'; $field = $this->modules->get('InputfieldPage'); $field->inputfield = 'InputfieldSelect'; $field->findPagesSelector = 'parent_id=1538, include=hidden'; $field->labelFieldName = 'salutation'; $field->name = 'salutation'; $field->columnWidth = 16; $fieldset->add($field); I can create the first fieldset (Customer Source) but then get into trouble as the second fieldset overwrites the first. I understand why, but trying to use the open and close fieldset routine has flummoxed me. Any help appreciated.
-
Hello forum, we're trying to use Processwire as our REST-API. We are having problems with our API login to Processwire from frontend. It gives us 403 error. We have installed ProcessWire to subdirectory (/api/*) and our frontend is static JS files at root ( / ). Apache access logs gives 404 to our POST-request, but browser devtools shows 403 for our POST /api/login request. Processwire backend panel works. We also have a GET endpoint for the API that returns 200 with correct payload. So we're wondering why does our GET works but POST doesn't? Does this have something to do with Processwire .htaccess, or is this because of our webhost? What should we check first? Any help would be appreciated.
-
Hi everyone It seems that I don't fully understand the wireTempPath() function and I need some help. I use wireTempPath() to create a new location in assets/cache/WireTempDir and than copy a pdf from the assets/files/page folder to the new folder. I want the file to be accessible only for a limited time, that's why I use wireTempPath. The file seems to be copied to the right location, but gets deleted right afterwards, according to As mentioned in the topic above, $wireTempDir->setRemove(false); prevents the file to be deleted. But I like the file to be automatically deleted after a few days. So, how can I do that? My code so far (everything works, but the automatic removal of the tempDir folder): //generate and show download link $folder = time(); // timestamp as temporary folder $maxAge = (int) $settings->options_downloadlink_valid_hours * 3600; //tempDir wants maxAge as seconds $options = array( 'maxAge' => $maxAge ); $wireTempDir = wireTempDir($folder, $options); $wireTempDir->setRemove(false); $src_file = $page->ebook_download->filename; // Create a new directory in ProcessWire's cache dir if(wire('files')->mkdir($wireTempDir, $recursive = true)) { if(wire('files')->copy($src_file, $wireTempDir)){ //get subdirs from tempDir: $pos = strpos($wireTempDir, "WireTempDir"); $subdir = substr($wireTempDir, $pos, 100); $out .= "<p><a href='" . wire('pages')->get('template=passthrough')->httpUrl . "?file=" . $subdir . $page->ebook_download->basename . "' target='_blank'>$page->title</a></p>"; } } I appreciate any ideas - thanks! Oliver
-
Hi, is there a hook after the current (active) page got created? Or which method got called in the Page class after the Constructor of the current page got initialized? Thanks.
-
I am very sorry for asking this but i totally do not understand how to set values of checbox using API. I have checbox field on my page with name "order_status". So i've tried few ways to make it checked but it still doesn't work: $userPage->order_status->value = 1; $userPage->order_status->add(1); $userPage->order_status->add(true); Could you please tell me how to do it?
-
Hi guys, the field "redirect_last" of type DateTime got not updated. The update on the field "redirect_counter" works and got saved. Does anybody know what I did wrong in my code? if ($input->urlSegment(1) === 'redirect') { $page->of(false); $page->redirect_last = time(); $page->redirect_counter += 1; if ($page->save('redirect_counter')) { $session->redirect($page->website_url, 302); } } Thanks.
-
Dear all, I'm upgrading an older side with the new custom fields for images feature as of 3.0.142. My image field is set to "Automatic" and holds a bunch of images together with their respective description on each page. New custom fields include "caption" among others and to make my live easier I I'm trying to populate "caption" with the value from the (default) description field. But unfortunately I can't seem to find out how to save the newly set values. This is my code: <?php foreach (page()->images as $image) { $image->set('caption', $image->description); bd($image->caption); echo files()->render("markup/views/view-card-image-fancybox.php", array('image'=>$image)); } ?> <?php $page->save(); bd($page->save()); ?> This sets the value as intended (see screenshot) but doesn't save it permanently to the database. What am I doing wrong? Thanks!
-
As an admin I want to use the API to ask if a page is published - using the $page->isPublished() method - so that I know it's published - as opposed to unpublished or trashed pages. That includes hidden pages. This method will correspond to Settings -> Status when editing pages: (Published is also mentioned explicitly where the edit page says "Published on [?]".) I would expect the API - and specifically the $page->hasStatus() method - to ask if a page has status published. But as I can see, it's only possible to ask for exceptions such as isUnpublished() and isHidden(). <?php // This fails with "Fatal Error: Uncaught Error: Undefined class constant 'statusPublished'" if($page->hasStatus(Page::statusPublished)) { echo 1; } ?> PS: My current use case is that I want to count number of published vs. unpublished pages. I can only do that by getting all pages (include=all), then subtract any unpublished pages.
- 2 replies
-
- api
- ispublished()
-
(and 1 more)
Tagged with:
-
My clients wants a modal to show up on every page. But when a user clicks inside the modal -> a session-cookie is set and the modal gets a class. // user clicks on modal button $('.modal_button').click(function(){ // 1. set PW session cookie // 2. toggle class $('.modal').toggleClass('off'); }); I know how to set a cookie on page-load via PW-API. But the click on the modal button does not force a page-load. So i have to set the cookie through javascript. Is there a way to do that?
-
Hello, I'm trying to create a page via api and populate values to it. I can populate everything except user pages to a page reference array. Code: $dataUsers = $data->project->users; foreach($dataUsers as $dataUser) { $newProject->projectUsers->add(wire()->pages->find('template=user, id=' . $dataUser->id)); } I'm receiving my data via JSON. Is there something I'm missing? Thanks for help
-
Hi! I have been struggling with this for the last few hours and could not find a solution for it anywhere on the forums. I want to create a repeater field using the API and then add fields to it programatically. I can create the field and assign it to a template alright, but I can't assign any fields to the repeater itself. I've tried using $field->repeaterFields when creating the field but cannot figure out what it's supposed to accept. I tried passing it an array of IDs as well as a fieldgroup, but I couldn't get either to work. Any ideas?