-
Posts
6,798 -
Joined
-
Last visited
-
Days Won
158
Everything posted by Soma
-
New user role only selectable when it has "edit" permission
Soma replied to Soma's topic in General Support
there's a publish button? Ok I'm guilty! :D While at it, it always looks strange when creating roles,users,permission that is says "Add new page" ... -
I create a new role "media" that has only "view" access permission. I create a new user "media" , and when on the profile page the new "media" role doesn't show up in the role list. I add "edit" permission to the "media" role. It suddenly appears in the role list so I can add it to the user. After removing the "edit" permission again from the media role, it stays there.
-
Not sure but asking anyway. You certainly know that you have to enable page numbers on template url settings to get pagination to work? Sorry if you already knew.
-
And I was not here! Very nice example of usage of ProcessWire modules. Even after months, I love it!
-
Sorry for the harsh answer You might not be clear with that this form example IS php. There's no PW related in here, apart from the $input->post. But that's just equal to $_POST. How about doing a simple array with the field names required, and use that in the foreach check over those. You'll find plenty examples..
-
Yes. http://bit.ly/IkP4qF
-
I created a simple blank install profile for ProcessWire. I think it has been asked for a couple times, although the basic site is something really good to start with and fast to get rid of things you don't need. However in case someone wants one here it is. https://github.com/s...ireBlankInstall PROCESSWIRE 2.+ BLANK INSTALL ============================== This is a blank site profile for ProcessWire2+. It's done using the ProcessExportProfile module. There's only the following left in this profile: Fields: - title - body ProcessWire Templates - home - basic-page Template Files - admin.php (required) - home.php (required root page) - basic-page.php (404 page) INSTALLATION ============================= Get the latest ProcessWire install package. Before you install, replace the folders /basic-site/install /basic-site/templates with the ones from this blank install. Proceed with the installation as usual.
-
You're welcome, it's just a matter of debugging it right. You'll get more experienced the more you try to. The print_r will just output the array in a readable format. It's a method to bebug, see it somethings there. You can remove it. The alternative : is for if and foreach's in php you can do this to wrap instead of the curly brackets {}. It's easier if you're mixing html and php and instead of the closing } you write "endif;" or "endforeach;" - If you want an else in a if condition you write "else:". <?php foreach($a as $B) : ?> <p><?php echo $b</p> <?php endforeach; ?> <?php if($a == $B) : ?> <p><?php echo $b</p> <?php else: ?> <p>not same</p> <?php endif; ?> I moved the main php logic of the form to the top. This because I like it to have this way from top to bottom logic. I'm not saying you abolutely should do it that way, but for me it looks littler cleaner. There's also different approaches. (I'm sure diogo will post something else ) This way I have set a $success var to be false and wrap the form into the if(!$success): and also print any errors before the form. And then in the else: of the if(!$success) is true have the success message printed and the form will not be shown.
-
The problem seems that you're checking for $input->post->submit, yet the submit button has no name="submit", so it never enters the code in the if. I restructured a little your code. There's still a lot to improve, but you get the idea: <?php include("./head.inc"); $success_message = "<h2>Thank you, your message has been sent.</h2>"; $success = false; // we assume it and set to true if mail sent $error = false; // set and sanitize our form field values $form = array( 'name' => $input->post->name, 'email' => $input->post->email, 'phone' => $input->post->phone, 'subject' => $input->post->subject, 'level' => $input->post->level, 'hours' => $input->post->hours, 'message' => $input->post->message ); print_r($form); // check if the form was submitted if($input->post->submit) { // determine if any fields were ommitted or didn't validate foreach($form as $key => $value) { if( strlen(trim($value)) == 0 ) { $error_message = "<h2 class='error'>Please check that you have completed all fields.</h2>"; $error = true; break; } } // if no errors, email the form results if(!$error) { $emailTo = 'me@me.com'; if(empty($emailTo)) $emailTo = $users->get($config->superUserPageID)->email; $subject = "Contact Form"; $message = ''; foreach($form as $key => $value) $message .= "$key: $value\n"; if(mail($emailTo, $subject, $message, "From: $form[email]")){ $success = true; } } } ?> <?php if(!$success) : // : alternative version instead of {} ?> <?php if($error) { echo $error_message; // or pull from a PW field } ?> <p class="italic_header">If you'd like to get in touch regarding tuition, please use the form below.</p> <form action="./" method="post" id="contact_form"> <fieldset class="first"> <h6>About yourself: </h6> <label for="name">Your name: </label> <input type="text" name="name" autofocus> <label for="email">Your email: </label> <input type="email" name="email"> <label for="phone">Your phone number: </label> <input type="phone" name="phone"> </fieldset> <fieldset> <h6 class="mt60">Your tuition: </h6> <label for="subject">Subject: </label> <select name="subject" id="subject" /> <?php foreach ($page->subject_options as $subject) { echo "<option>$subject->subject_option</option>"; } ?> </select> <label for="level">Level: </label> <select name="level" id="level" /> <?php foreach ($page->level_options as $level) { echo "<option>$level->level_option</option>"; } ?> </select> <label for="hours">Hours per week: </label> <input type="number" min="1" max="40" value="2" name="hours"> </fieldset> <div class="clear"></div><!-- /.clear --> <fieldset class="full"> <label for="message">Additional information: </label> <textarea name="message" cols="30" rows="10"></textarea> <input type="submit" name="submit" value="submit" id="submit"> </fieldset> </form> <div id="contact_side"> <?php else: // if success ?> <?php echo $success_message; ?> <?php endif; // end if success ?> <h6>Or you can find me, here: </h6> <ul> <li>Skype: <?php echo $page->skype_name; ?></li> <li><a href="<?php echo $page->fb_url; ?>" target="_blank">Facebook</a></li> <?php if ($page->twitter_url) { echo "<li><a href='$page->twitter_url' target='_blank'>Twitter</a></li>"; } ?> </ul> </div> <!-- end contact side --> <?php include("./foot.inc");
-
I'm also using Chrome 18.01... on Mac OS X 10.6.8 Edit: actually after trying again it stopped working. When clicking "preview" it does nothing. This is from js console when clicking: POST http://test.ch/about/ f.support.ajax.f.ajaxTransport.sendJqueryCore.js:18 f.extend.ajaxJqueryCore.js:18 (anonymous function)/processwire/page/edit/?id=1001:634 f.event.handleJqueryCore.js:17 f.event.add.i.handle.k I have the latest and cleared cache. Same when using FF.
-
Welcome back Ryan!
-
It works (always) for me. Maybe some other things included that is disturbing?
-
Easiest way for clients to add select options in form
Soma replied to onjegolders's topic in General Support
Pages are great for this. A recent new feature allows you to add pages in a page select, you can enable it in the fields input settings. Using pages you could setup a section for the user to add pages used as options later, and even sort them in the tree. No need to even have a select page field on the page. You could also just use that "section" and it's childs to output the options. echo "<select name='myoptions'>"; foreach($pages->get("/myoptions/")->children() as $option){ echo "<option value='$option->name'>$option->title</option>"; } echo "</select>"; or if through a page select field "select_options" on page it would be echo "<select name='myoptions'>"; foreach($pages->selet_options as $option){ echo "<option value='$option->name'>$option->title</option>"; } echo "</select>"; Other ways would be to have a textarea and each new line render as an option. Then the code would be like this: in optionstext field: Option1 Option2 Option3 echo "<select name='myoptions'>"; foreach(explode("\n",$page->optionstext) as $option){ echo "<option value='$option'>$option</option>"; } echo "</select>"; -
Thanks Nico. Any news to issue #2? I noticed another problem when submitting a front-end form and have this module installed I get this error: Error Exception: You must assign a template to the page before setting custom field values. (in /Applications/XAMPP/xamppfiles/htdocs/pw-dev/wire/core/Page.php line 335) #0 /Applications/XAMPP/xamppfiles/htdocs/pw-dev/site/modules/ProcessPreview/ProcessPreview.module(38): Page->setFieldValue('_form_id', '35cf3e112fd7061...') #1 /Applications/XAMPP/xamppfiles/htdocs/pw-dev/wire/core/Wire.php(291): ProcessPreview->changeView(Object(HookEvent)) #2 /Applications/XAMPP/xamppfiles/htdocs/pw-dev/wire/core/Wire.php(229): Wire->runHooks('execute', Array) #3 [internal function]: Wire->__call('execute', Array) #4 /Applications/XAMPP/xamppfiles/htdocs/pw-dev/index.php(198): ProcessPageView->execute() #5 {main}
-
it will work just change it to this. ... if ($blog_entry->getItemKey($entry) % 2) {$class .= ' blog_box_even';} if ($entry == $blog_entry->first()) {$class .= ' blog_box_first';} elseif ($entry == $blog_entry->last()) {$class .= ' blog_box_last';} ...
-
It is possible $field2 = $page->field2; $result = $pages->find("template=something, field1>$field2"); Edit: ah hehe, ok this is what you're looking for. $results = new PageArray(); foreach( $pages->find('template=something') as $p) { if($p->field1 > $p->field2) $results->import($p); } Anyway have you tried your version if it would work?
-
There's an option underneath the templates fields to use fieldset of another template.
-
like this: <?php $testimonial = $page->children(); foreach ($tm as $item) { $class = ''; $count = $tm->getItemKey($item) + 1; if(!0 == $count % 2) $class = 'odd'; if($tm->first() === $item) $class .= ' first-item'; if($tm->last() === $item) $class .= ' last-item'; ?> <div class="testimonial_box<?php echo " $class"; ?>"> <?php echo $item->body; ?> <p><?php echo $item->title; ?></p> </div> <?php } ?>
-
onjegolders, look at my first example. ->first(), ->last() can also be used. But that limits it to first and last. With $pagearry->getItemKey($page) you can get the position index 0,1,2,3... So you can use $count = $array->getItemKey($page) + 1; to get the count for each loop.
-
How can end-users add gaps/margins in TinyMCE?
Soma replied to onjegolders's topic in General Support
You can add custom configuration in TinyMCE. In the field settings under "Input" tab. You find the "TinyMCE Advanced Configuration Options". There you find some fields to overwrite settings. You could try the options in TinyMCE for newlines behaviour. Though I'm not sure, since I don't use them, what would be what you need. http://www.tinymce.c...rce_br_newlines In the setting field "Additional TinyMCE settings" you have a textarea to specify configs in a key:value format, each on a newline. So you could add these (no apostrophes needed or endline ","): force_br_newlines : true force_p_newlines : false -
http://caniuse.com/#search=first If you still support IE6 it's not, but there's polyfills in case. there's common techniques in programming that goes beyond PW API or php. something like this for example? $i = 0; foroeach($pa as $p){ $i++; if(0 == $i % 2) $class = ' class="last-row"'; echo "<div$class>$p->title</div>"; }
-
Thanks for the update. The save button now works. 1. When debug mode on, it breaks the admin. Notice shows up and page tree doesn't get loaded. Notice: Undefined index: id in /.../site/modules/ProcessPreview/ProcessPreview.module on line 31 2. Still, when I open a page, edit something in the text, click "preview" it opens window, but the text change isn't there. When I close the window and hit "preview" again, it shows the updated text. Which means it only works every 2th time I hit "preview" when I change a text. In other words, everytime I change a text I have to open "preview" 2 times to see the change.
-
CSS: .box::first-child{} .box::last-child{} in Processwire API PHP foreach($pagearray as $p){ if($p === $pagearray->first()) ....; if($p === $pagearray->last()) ....; echo ... }
-
Well, it doesn't. Save button is broken after using "preview" ones. And the preview only shows the changed text every 2th time I click "preview".