Wanze
PW-Moderators-
Posts
1,116 -
Joined
-
Last visited
-
Days Won
10
Everything posted by Wanze
-
You're welcome Roope. In ryans module, parent is an instance variable of the module. That's why he can refer to $this->parent. See here: /** * Instance of Page, representing the parent Page for imported pages * */ protected $parent = null; // Later in code... $this->parent = $this->pages->get($this->session->csvParent);
-
$this always refers to the class , which is your module (e.g. instance of WireData / Process...). Are your sure that $name holds a string of your 3 keys? if (!isset($this->fieldTypes[$name])) die("Bad bad $name, this key does not exist in my array!");
-
You can extend the user template with an files field, then each user can hold multiple files. Under Setup > Templates > Filter > Show system templates => yes. Now you can select the user template and add custom fields e.g. a files field
-
(#$%^) Watch Fast & Roderigo Meat Boat Movie in the Nude @
Wanze replied to levies28's topic in General Support
lol -
But the page with id 1040 is already in the array. Just add another page that's not there - that should work.
-
Hi Roope, product_group is a PageArray, so you have to add the page to that array: $demo->product_group->add(1040); // If above doesn't work, try: $demo->product_group->add($pages->get(1040));
-
Ah! Yeah urlSegment1 returns nothing, because there's no. When reading a post, you are on a page with template 'post'. The last segment in the url is the page's name. If you'd add after that another segment yourself, this would be the first urlSegment then. But to solve your problem: foreach ($posts as $item) { if ($item->id == $page->id) continue; } This will then result in $limit-1 posts, so you could also exclude the current page at db level: $posts = $pages->find("template=post, sort=-date, start=0, limit=$limit, id!={$page->id}");
-
Hi Roope, Is product_group a Page field and 1040 the ID of a page? If so, does the page exist and is it allowed for your page field?
-
Updating Repeaters via API - without removeAll()
Wanze replied to renobird's topic in General Support
Glad it works for you! I think you can delete this line: $rp = $pages->get("id=$expense->id"); // the repeater page we want to update You should have the same page already in your $expense variable from the foreach loop. -
But when I enter an email address from another person - forget my password - then the email gets sent to that adress. I still would have to hack the persons email account to reset the password?
- 6 replies
-
- ProcessProfile
- UserEdit
-
(and 1 more)
Tagged with:
-
I think that Pw returns null if a POST variable isn't set. So this should also work: if (!is_null($input->post->list)) {} if ($input->post->list !== null) {} // Simplest but be careful when list contains the value '0' - this is casted to false if ($input->post->list) {} You get the warning from PHP if your array is empty and you want to iterate over it - that's why you always should first check if the variable is set / contains values. Quote from the docs: $input returns NULL if you access a variable that doesn't exist (no need to use isset() like with PHP's superglobals) http://processwire.com/api/variables/input/
-
Updating Repeaters via API - without removeAll()
Wanze replied to renobird's topic in General Support
Hi renobird, I did a quick test and it worked for me. Just updated the first page of a repeater field with the API: $firstPage = $pages->get('/myRepeaterPage/')->repeater_field->first(); $firstPage->of(false); $firstPage->field = 'new value'; $firstPage->save(); Can you post some example code? Cheerio -
Hi enibas I wouldn't setup the redirects in the htaccess. Instead use $session->redirect() You have url Segments enabled for both project template and donation form? Then something like this should work for the redirect: // In project template if ($input->urlSegment1 == 'donation') { $donationPageUrl = $pages->get('/stuff/donation/')->url; $redirectUrl = $donationPageUrl . "{$page->name}/{$page->parent->name}/{$page->parent->parent->name}/"; $session->redirect($redirectUrl); } But why you need the redirect? Can't you use a normal link to your donation page? Also why do you reverse the path? Otherwise the redirectUrl is simpler to build: // This should result in /stuff/donation/continent1/land1/project11/ $redirectUrl = rtrim($donationPageUrl, '/') . $page->url;
-
Hi patrik, You can use urlSegments for this case. In your template used by the /author/ page, enable urlSegments in the Template config. Then in the template file (example code): if ($input->urlSegment1) { $username = $sanitizer->selectorValue($input->urlSegment1); // Maybe you need to add 'check_access=0' to your selector if also guest users can see this page... $u = $users->get($username); if ($u->id) { // Display the information about user } else { throw new Wire404Exception(); } } // No urlSegment passed - throw a 404 or output some message
-
Hi sakkoulas, That's because the standard font set by the module does not have those characters included. I removed all fonts but the standard ones from the tcpdf folder so the module doesn't get too heavy. You can do those steps: Download TCPDF Copy all files starting with freesans* or freeserif* to /site/modules/Pages2Pdf/tcpdf/fonts In your module configs, set freesans/freeserif under Default font Then the greek characters work (make sure you enable debug mode or save the page to delete any cached pdfs). I think this is the easiest solution. Disadvantage is that the pdf is a bit heavier due to this font which includes all unicode characters. Another possibility is to convert a greek font to TCPDF according to the docs: http://www.tcpdf.org/fonts.php Does this work for you?
-
Repeater and Colorpicker: different colour for each repeater
Wanze replied to Alex's topic in General Support
Hi alex, <style> tags are normally inside the <head>, as far as I know. You can set the chosen color inline: foreach($page->repeater as $p) { echo "<div style='background-color: #{$p->colour_picker};'></div>"; }- 8 replies
-
- 2
-
- repeater
- colorpicker
-
(and 1 more)
Tagged with:
-
@everfreecreative You have to write: throw new Wire404Exception();
-
Hi valan, I've found a solution. The translations of the labels (not default) are stored in the 'data' field in the 'fields' table, as JSON. Example: {"label1012":"Weight"} where 1012 is the ID of the language. You can try this code: $label = 'label'; if ($user->language->name != 'default') { $label = "label{$user->language}"; } // Output label in correct language echo $user->fields->get('field')->$label;
-
Hi Peter, Set your pages to 'hidden'. This way they won't show up in searches unless you add include=hidden into your selector. Do your data pages have a template file associated or just hold data? If there's no template file, then the pages are not accessible in the frontend anyway because Pw will throw a Wire404Exception (page not found). If the data pages have a template file, then you could check on top of that if the user is SuperUser or has a certain role: // In your template file if (!$user->isSuperUser()) { throw new Wire404Exception(); } // OR if (!$user->hasRole('superAdmin')) //...
-
Thumbnail Module: Test If An Image Field Contains A Thumbnail
Wanze replied to bytesource's topic in Modules/Plugins
Sorry, I was wrong. type exists on the field object. So this should also work: if ($fields->get('yourImageFieldName')->type == 'FieldtypeCropImage') { // Thumbnail FieldtypeCropImage is the Fieldtype used by a thumbnails image field. -
Hi andy, welcome to Pw I don't understand what you want to do, can you post some example code? It depends where you are calling $input->urlSegment1. If this is on a template with urlSegments enabled and returns nothing, then there is no urlSegment available. To get the url of the actual page viewing, use: $page->url; CHeers
-
Hi onjegolders, I've never seen this before. Could you check if you see the content also by viewing the statistics in the normal UI from google?
-
Is it possible to add a field to a specific user role?
Wanze replied to Jonathan Lahijani's topic in General Support
You're welcome. Here's a good overview how Hook works: http://processwire.com/api/hooks/ Also checkout the captain which shows you all the hooks available: http://somatonic.github.io/Captain-Hook/ And here an example, written in the browser and not tested: // Inside your autoload module you have installed... public function init() { $this->addHookAfter('ProcessPageEdit::buildForm', $this, 'hideFields'); } public function hideFields(HookEvent $event) { // Do nothing if we don't edit a user if ($this->page->template != 'user') return; // Get the form instance returned from the hooked method $form = $event->return; // Define fields to hide per role $hideFields = array( 'role1' => array('field1', 'field40'), 'role2' => array('field5', 'field2'), ); // Hide the fields foreach ($hideFields as $role => $fields) { if ($this->user->hasRole($role)) { foreach ($fields as $field) { $f = $form->get($field); $f->collapsed = Inputfield::collapsedHidden; } } } $event->return = $form; } -
Is it possible to add a field to a specific user role?
Wanze replied to Jonathan Lahijani's topic in General Support
I would assign all the fields and just fill out the ones needed depending on the role. Like I said, if you don't want the user to see the unecessary fields in the backend, you could hide them. Maybe someone comes up with another solution, there are always multiple with Pw -
Is it possible to add a field to a specific user role?
Wanze replied to Jonathan Lahijani's topic in General Support
Hi jlahijani, If you assign a field to a user template, then all users get that field. Can you explain a bit more why you need this behaviour? It would be easy to hide this particular field for all other roles with a hook.