• Content count

  • Joined

  • Last visited

Community Reputation

4 Neutral

About nico65

  • Rank
    Jr. Member

Recent Profile Visitors

428 profile views
  1. Thank you gmclelland, I'll take a look at the module, looks promising. ...ok, I have a modified version of the twig module for the "TemplateEngineFactory" Module. If someone is interested:
  2. Hi, I’m trying to implement mustache.php into processwire. What I did so far and what worked with one problem is: put the “Mustache” Folder in site/template make a _init_mustache.php <?php // include Mustache require __DIR__ . '/Mustache/Autoloader.php'; Mustache_Autoloader::register(); //start the mustache engine $mustache = new Mustache_Engine(array( 'template_class_prefix' => '__MyTemplates_', 'cache' => dirname(__FILE__).'/tmp/cache/mustache', 'cache_file_mode' => 0666, // Please, configure your umask instead of doing this :) 'cache_lambda_templates' => true, 'loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/Pattern'), 'partials_loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/Pattern/Partials'), 'helpers' => array('i18n' => function($text) { // do something translatey here... }), 'escape' => function($value) { return htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); }, 'logger' => new Mustache_Logger_StreamLogger('php://stderr'), 'strict_callables' => false, )); call that _init_mustache.php in the _init.php include_once("./_init_mustache.php"); Now I have a site/template/portfolio.php where I call the template $tpl = $mustache->loadTemplate('02-objects-050-image-hovertext'); // loads __DIR__.'/views/foo.mustache'; $content .= $tpl->render(array( 'alltagstitle' => $alltagtitle, 'order' => '01', 'Title' => $title, 'SRC' => $resized_thumb->url, )); this works so far in but I also call it from here fields/gcp/portfolio.php $temp = wireRenderFile($config->paths->templates.'/portfolio.php'); $search = explode(",", $srch); $replace = explode(",", $rplc); $newtemp = str_replace($search, $replace, $temp); echo $newtemp; to include the portfolio part on other pages. (I use the module “fieldtype select file”) My problem is now, that on the page where I use that last method I get the error: Error: Call to a member function loadTemplate() on null (line 71 of /var/…./site/templates/portfolio.php) And the Notice: Notice: Undefined variable: mustache in /var/www/clients/client29/web166/web/eyeonu-v6/site/templates/portfolio.php on line 71 Fatal error: Call to a member function loadTemplate() on null in /var/www/clients/client29/web166/web/eyeonu-v6/site/templates/portfolio.php on line 71 line 71 is: $tpl = $mustache->loadTemplate('02-objects-050-image-hovertext'); // loads __DIR__.'/views/foo.mustache'; It looks that I somehow messed it up with the prependtemplatefiles, can anyone give me a tip?
  3. Hello I just saw, that you can render fields and repeaterblocks within their own templates. That's pretty Cool! I have a nested repeater block "gcb" that is rendered in: /site/templates/fields/gcb.php But this is just a switch, because in the repeater block is a selectfield, which tells the repeater block which sub field template it should use to render. E.g.: plain, spezialitaeten, tools These templates are all in the "gcb" subfolder: /site/templates/fields/gcb/plain.php /site/templates/fields/gcb/spezialitaeten.php /site/templates/fields/gcb/tools.php My Question now is, is there a easy solution to have a selectbox that lets you select between the file in the folder: /site/templates/fields/gcb/ Because right now, I have to update this selectfield manually, with the possible options.
  4. nico65

    Hello, first of all thanks for the module, makes creating contactforms a breeze! I have a just a minor question, is it possible to alter the markup of the submit button? I tried it like this: $options = array( 'emailAdd' => true, 'markup' => array( 'button' => "<button {attrs}><span><span>{out}</span></span></button>" ), 'btnClass' => 'button ghost small', 'btnText' => 'Senden', 'emailAddReplyTo' => $input->scf_contact_mail ); But the markup part, wasen't applied to the form. Is there a way, I know I could archive whtat I want also with css but I'd rather like to have consistant buttons.
  5. nico65

    Thanks a lot, that worked!
  6. nico65

    I'm also not able to use include or wireRenderFile in my Hanna Code. I always get Error 500 I can call my portfolio.php in my home.php template file like this: $temp = wireRenderFile("./portfolio"); // In this case we need a return $content in portfolio.php $content .= $temp; or this: include("./portfolio.php"); but this won't work in Hanna Code. If I paste the whole portfolio.php code into the hanna code it works too, but I would rather not to manually copy the stuff into Hanna Code everytime I edit the File. I'm on PW V.3.0.35 If anybody has an idea...
  7. nico65

    The main reason was actually, when creating the "Snippet" in frontend I redirected to the new page and opend the modal automatcly via jquery. This just looked and felt a little weired. I thought it might look better beeing redirected directly to the edit page. Another thing is that I try to have more the look and feel of the frontend instead of the backend, but this is something I can figure out later. And LostKobrakai thanks for the tip without the modal template, but that would be too much backend for my taste
  8. nico65

    Thank you Bernhard, for your suggestions, but I think, since I use PW3, I think I don't need Fredi or Feel. My intention is also to not have a modal popup. Another idea is to redirect directly to the modal url e.g. "page/edit/?id=1115&s=1&modal=1&fields=snippet_repeaterblock,snippet_tag&changes=snippet_repeaterblock" But here I need to alter the template. Add Header/Footer maybe a css File and a "Back to Page" Button. Has someone an Idea how to archieve that?
  9. nico65

    Hi Robin, thank you, I'll try that. what I try to do, is having a system where frontend user can create and maintain code snippets. So in the frontend they create a new snippet page and then they are redirected to the page where they can edit all the fields. Repeater, Tags, Images etc. What, I did first and what works was to open the edit modal after getting to the newly created page. But somehow I think it would be a little bit more elegant if the editing would happen in an extra page. since I'm new to pw this project is just to get familiar with the system and the different possibilities.
  10. Hello, the frontend edit mode in pw3 is allready great. But I'n looking for a solution where I can have the create/update form on a edite page. (url/urlsegmaent=edit). With all the released code here I was able to put together some code that does that. So far it works to fill the page for the first time, but unfortunaly it dosen't work so great on updating the page. When I try to update, the page disappears from the frontend. Its still visible in the backend but seems to be corrupt. Here is the code I used: <?php namespace ProcessWire; ?> <?php $content =''; ?> <?php $content = ''; $out = ''; if ($input->urlSegment(1 ) =='edit'): if(!isPageOwner()) throw new Wire404Exception(); // Edit Form // get a page $editpage = $page->setOutputFormatting(false); $ignorefields = array("isOld","user_activation","language_published","roles","admin_theme"); $form = $modules->get("InputfieldForm"); $form->method = 'post'; $form->action = './'; // get the collection of inputs that can populate this page's fields $inputfields = $editpage->getInputfields(); // make all the fields required and add them to the form foreach($inputfields as $inputfield) { if(in_array($inputfield->name, $ignorefields)) continue; $form->add($inputfield); } // the inputfields don't already have a submit button, so we'll add one. $submit = $modules->get("InputfieldSubmit"); $submit->name = "submit"; $submit->value = 'Submit'; // add the submit button the the form $form->add($submit); // process the form var_dump($editpage->snippet_repeaterblock->first()); echo '<hr>'; var_dump($editpage->snippet_repeaterblock); echo '<hr>'; $rpf_count = $editpage->snippet_repeaterblock->count(); echo $rpf_count; if($this->input->post->submit) { echo $firstRepeaterId; $n = 1; $codesnippet = "snippet_code_repeater$n"; $codelanguage = "snippet_select_codelanguage_repeater$n"; $snippet_repeaterblocks = $editpage->snippet_repeaterblock; // the repeaters foreach ($snippet_repeaterblocks as $item){ # $item = $pages->get("id=$snippet_repeaterblock->id"); // the repeater page we want to update $item->of(false); // update repeater fields $item->snippet_code_repeater = $input->post->$codesnippet; $item->snippet_select_codelanguage_repeater = $input->post->$codelanguage; // save the repeater page $item->save(); // update counter etc $n++; $codesnippet = "snippet_code_repeater$n"; $codelanguage = "snippet_select_codelanguage_repeater$n"; } # New Code End // now we assume the form has been submitted. // tell the form to process input from the post vars. $form->processInput($this->input->post); // see if any errors occurred if( count( $form->getErrors() )) { // re-render the form, it will include the error messages $out .= $form->render(); } else { // successful form submission, so populate the page with the new values. foreach($form as $field) { $donotpopulate = array("snippet_repeaterblock"); if(in_array($field->name, $donotpopulate)) continue; $editpage->set($field->name, $field->value); echo $field->name; echo ':'; echo $field->value; echo '<hr />'; } // save it $editpage->of(false); $editpage->save(); $out .= "Page saved."; $out .= $form->render(); $content .= $out; } } else { $out .= $form->render(); $content .= $out; } else: ?> <?php /* -------------------- UserProfile */ ?> <?php $cuser = $page->createdUser->id; ?> <?php $cusername = $users->get($cuser)->name; ?> <?php $cusermail = $users->get($cuser)->email; ?> <?php # print_r($page->createdUser); ?> <?php /* -------------------- TAGS*/ ?> <?php $snippet_tag_count = count($page->get("snippet_tag")); $allsnippettags = $page->get("snippet_tag"); if ($snippet_tag_count > 0 ): $tagcontent ='<ul class="snippet_tags">'; $tagcontent =''; $tagcontent .='<ul class="all-tags">'; foreach ($allsnippettags as $allsnippettag) : $alltagtitle = $allsnippettag['title']; $alltagid = $allsnippettag['id']; $alltagpath = $allsnippettag['path']; $alltagurl = $baseurl.$alltagpath; $tagcontent .='<li class="all-snippet_tag">Tag: <a href="'.$alltagurl.'">'.$alltagtitle.'</a>'; # print_r($allsnippettag); ?> <?php $tag = $allsnippettag['name']; $matches = $pages->find("snippet_tag=$tag"); $matchescount = count($matches); $tagcontent .='<ul class="tags">'; foreach ($matches as $match) : $tagtitle = $match['title']; $tagid = $match['id']; $tagpath = $match['path']; $tagurl = $baseurl.$tagpath; $tagcontent .='<li class="snippet_tag "><a href="'.$tagurl.'">'.$tagtitle.'</a></li>'; endforeach; $tagcontent .='</ul>'; $tagcontent .='</li>'; endforeach; $tagcontent .='</ul>'; endif; ?> <?php $content .= "<div id='snippet' edit='snippet_repeaterblock,snippet_tag'>"; $content .= "<p>Create Snippet</p>"; foreach ($page->snippet_repeaterblock as $repeater_item) { if ($repeater_item->get("cb_desc_code")): $content .= "<div class='snippet_description'>" . $repeater_item->get("snippet_description") . "</div>"; else : $content .= "<pre><code>" . $repeater_item->get("snippet_code") . "</code></pre>"; endif; } $content .= '</div>'; $content .= $tagcontent; $content .= '<div class="CreatedUser"><a href="'.$baseurl.'snippets/'.$page->createdUser.'" >'.$cusername.'</a></div>'; If someone has some ideas that would be great. Best Nico