Jump to content

Marcel Epp

Members
  • Posts

    86
  • Joined

  • Last visited

Everything posted by Marcel Epp

  1. OK it is working now. For the overview page i used: <p class="text-center">veröffentlicht am <?= $blog_post->page_published ?></p> And for my single blog page i used: <p class="text-center">veröffentlicht am <?= $page->page_published ?></p> So creating an extra field and put this in the single blog file is like a workaround.
  2. One solution i thought of is to create a new datetime field like "page_published". And when you create a new page the field get filled with the current date. But i can't output the field like the others. I build myself a little blog. <!-- the logic --> <?php $blog_posts = $pages->find('template=blog-single, limit=1, sort=-created'); ?> <?php foreach($blog_posts as $blog_post): ?> <?php $blog_post_publish_date = date('d.m.Y', $blog_post->published); $blog_post_created_by = $blog_post->createdUser->name; ?> But when i change $blog_post->published to $blog_post->page_published i get an empty result. This is from the overview site from the blog.
  3. Hi Zeka, that solves the problem for the user. Tahnk you! But the second problem still persist. How can i change the published date in the admin area?
  4. Hi, i'm stuck here with a problem. I want to change the user that created a site. And i want to change the published date time. But i can't find an option in the admin area. Does Processwire have these options? Or is there a modul for that? thanks
  5. Yeah! awesome the active part makes it even better. 'currentItemClass' => "active"
  6. Hi Jonathan, thank you for your answer. That solved the problem! The code looks now like this: echo $images_posts->renderPager(array( 'nextItemLabel' => "Vorwärts", 'previousItemLabel' => "Zurück", 'listMarkup' => "<nav aria-label='Page navigation'><ul class='MarkupPagerNav pagination'>{out}</ul></nav>", 'itemMarkup' => "<li class='{class} page-item'>{out}</li>", 'linkMarkup' => "<a class='page-link' href='{url}'>{out}</a>", 'currentLinkMarkup' => "<a class='page-link' href='{url}'>{out}</a>" ));
  7. Hi, i am trying out Bootstrap 4. I want to build a site for my wife. Thanks to the forum i get the blog part done. But the pagination is not working as aspected. The first number of the pagination did not get styled. Only for the first and the last link there is a span and no class is asigned. echo $images_posts->renderPager(array( 'nextItemLabel' => "Vorwärts", 'previousItemLabel' => "Zurück", 'listMarkup' => "<nav aria-label='Page navigation'><ul class='MarkupPagerNav pagination'>{out}</ul></nav>", 'itemMarkup' => "<li class='{class} page-item'>{out}</li>", 'linkMarkup' => "<a class='page-link' href='{url}'>{out}</a>" )); result is: The markup from the first picture is not the same like the other. How can i change the markup for the first link, and the last link of course when i changed the site?
  8. I have searched for a solution. I would shorten the text from my blog entries. This seems to work for me. It keeps the html tags from the editor: function truncateHtml($text, $length = 100) { $current_size = strlen($text); $diff = strlen($text); $remainder = $current_size - $length; while($diff > 0 AND $remainder > 0) { $pattern = "/(.*)[^<>](?=<)/s"; $text = preg_replace($pattern, "$1", $text); $diff = $current_size - strlen($text); $current_size = strlen($text); $remainder = $current_size - $length; } // iff $diff == 0 there are no more characters to remove // iff $remainder == 0 there should removed no more characters return $text; } It's from here: https://stackoverflow.com/questions/38548358/cut-html-input-while-preserving-tags-with-php Post Number 4.
  9. Hi abdus, thank you very much! the category=$page think was the missing piece! Now my category pages list the blog posts that assigned to that category. I have to tweak it for me cause my field has another name: <?php $blog_category = $pages->find("template=blog-entries, categories=$page"); foreach ($blog_category as $category) { echo "<a href='{$category->url}'>{$category->title}</a> "; } ?>
  10. Hi, i'm trying to build a simple blog. Thanks to this forum it is working good. But i ran into a problem. How can i match my categories with the title? When i visit the page "Buchbinder" it should show me all pages that tagged with the category "Buchbinder" under "Neuigkeiten". How can i do that? My category page now looks like this: $blog_category = $pages->find("template=blog-entries"); foreach ($blog_category as $category) { echo "<a href='{$category->url}'>{$category->title}</a> "; } But how can i now say match the title from this site? thanks Marcel
  11. I think there is a missing ' <div<?php echo " style='background-image: url(" . $topleft->url . ")'; " ?>>
  12. Thanks dragan! and thanks maxf5 you really helped me out! It is working now. I think i mixed your last entries. The code i use now: // find the highest customer number $highest_customer_number = $pages->get("template=user, sort=-id, limit=1, roles=anzeigen-anbieter")->customer_number; // add +1 $customer_number_plus_one = $highest_customer_number + 1; //create user details $user = new User(); $user->of(false); $user->pass = rand_string(8); $user->email = $email; $user->customer_number = $customer_number_plus_one; $user->addRole("anzeigen-anbieter"); $user->save(); $user->of(true);
  13. Hi Rick, at the moment i didn't save the number. My first thought was to get the field (customer_number) and the latest number and echo that out. I would see if this would work. But for me it's not really clear how to get the number. I tried dragans way and my own.
  14. Or can i query the database direct? to get the latest number from the field?
  15. Hello dragan, thanks for your answer. I don't get it to work. If i use the code from above i get zero a 0. I tried to fetch the highest customer_number with $user. But this didn't work either. items = $users->find('sort=-id,limit=1,roles=anzeigen-anbieter');
  16. Hi, i'm looking for a solution to register users in the frontend. For the username i would use a number with 6 digits starting with 300000. I have set up a field called customer_number. It is possible to give the field a number and then count up. 300001 user1 300002 user2 At the moment my code looks like this: if($input->post->create_user_submit) { //instantiate variables taking in the form data $email = $sanitizer->email($input->post->user_email); if (in_array($input->post->email, $email)) { echo "<h5 class='error'>E-Mail is already in use.</h5>"; } else { //create user details $user = new User(); $user->of(false); $user->name = "Paul"; $user->pass = "max123"; $user->email = $email; $user->addRole("anzeigen-anbieter"); $user->save(); $user->of(true); } }
  17. @Pravin Hi Pravin, it's been a while since i played with processwire... My setup was a little bit confusing. I ended up having three files. As i look trough my files. When you have managed the upload, you probably have some sort of files array. In my files i used some part of wire upload i think. // RC: create temp path if it isn't there already if(!is_dir($upload_path)) { if(!wireMkdir($upload_path)) throw new WireException("No upload path!"); } // setup new wire upload $u = new WireUpload('file'); $u->setMaxFiles($max_files); $u->setMaxFileSize($max_upload_size); $u->setOverwrite($overwrite); $u->setDestinationPath($upload_path); $u->setValidExtensions($file_extensions); // start the upload of the files $files = $u->execute(); Now i had my "files" array. Then i put my xml code in. // create XML files for switch // remove extension from files $withoutExt = preg_replace('/\\.[^.\\s]{3,4}$/', '', $files); foreach($withoutExt as $withoutExt_string) { $doc = new DOMDocument('1.0'); // we want a nice output $doc->formatOutput = true; $root = $doc->createElement('phpemail'); $root = $doc->appendChild($root); $email = $doc->createElement('email'); $email = $root->appendChild($email); $text = $doc->createTextNode($newemail); $text = $email->appendChild($text); $doc->save($upload_path . $withoutExt_string . ".xml"); } hope it helps.
  18. Hi flydev, the code returns an internal server error. I will try to get it to work. Thank you.
  19. Hi, how can i change the deepness? I only want to go to level 1 (Tier2). I only need the parent and the child's. How can i do that?
  20. Hello Adrian, thanks for the information. Then i must fix this. I removed the redirect as mentioned by Soma. I now get a nice feedback after i change the password. <?php // txtConfirmPassword is the name of the field in my form! if($input->post->txtConfirmPassword) { $user->setOutputFormatting(false); $user->set('pass', $input->post->txtConfirmPassword); $user->save('pass'); echo "<div class='alert alert-success' role='alert'>Sucsess! You have a new password.</div>"; } ?>
  21. The redirect is not the best idea. For Validation i use some Javascript. And yes it is crappy Javascript..... still learning. // überprüft die Passworteingabe im ersten Feld function checkPasswordRegEx() { var password = $("#txtNewPassword").val(); var regex = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[0-9a-zA-Z]{6,}$/; if ( password === '' || password.match(regex) ){ $("#divCheckRegEx").removeClass(" alert-danger").addClass(" alert-success").html("Das Passwort erfüllt die Anforderungen!"); } else $("#divCheckRegEx").addClass(" mgt-15px alert alert-danger").html("Das Passwort erfüllt nicht die Anforderungen!"); } $(document).ready(function () { $("#txtNewPassword").keyup(checkPasswordRegEx); }); // versteckt die Meldung wenn leer $("#txtNewPassword").keyup(function(){ if($(this).val()) { $("#divCheckRegEx").show(); } else { $("#divCheckRegEx").hide(); } }); // prüft ob das zweite Feld mit dem ersten übereinstimmt function checkPasswordMatch() { var password = $("#txtNewPassword").val(); var confirmPassword = $("#txtConfirmPassword").val(); if (password != confirmPassword) $("#divCheckPasswordMatch").addClass(" alert alert-danger").html("Das Passwort stimmt nicht überein!"); else $("#divCheckPasswordMatch").removeClass(" alert-danger").addClass(" alert alert-success").html("Das Passwort stimmt überein."); } $(document).ready(function () { $("#txtConfirmPassword").keyup(checkPasswordMatch); }); // versteckt die Meldung wenn leer $("#txtConfirmPassword").keyup(function(){ if($(this).val()) { $("#divCheckPasswordMatch").show(); } else { $("#divCheckPasswordMatch").hide(); } });
  22. Hi Adrian, thanks for your reply! Removing this line brings nothing. But i got it to work! I reviewed my login frontend template and build it like this: First the php part: <?php // txtConfirmPassword is the name of the field in my form! if($input->post->txtConfirmPassword) { $user->setOutputFormatting(false); $user->set('pass', $input->post->txtConfirmPassword); $user->save('pass'); // after login redirect user to another page if($session->login($user)) { // login successful $session->redirect("/"); } } ?> And then i changed my form. I gave the second field a name tag: <form method="post" action="./" class="form-horizontal mgt-30px"> <?php if($input->post->user) echo "<h2 class='error'>Passwort Änderung fehlgeschlagen!</h2>"; ?> <div class="form-group"> <label for="txtNewPassword" class="col-sm-4 control-label">Neues Passwort:</label> <div class="col-sm-8"> <input type="password" class="form-control" id="txtNewPassword" name="txtNewPassword" onChange="checkPasswordRegEx();" placeholder="hier bitte das neue Passwort eintragen" required> <div class="registrationFormAlert" id="divCheckRegEx"></div> </div> </div> <div class="form-group"> <label for="txtConfirmPassword" class="col-sm-4 control-label">Passwort widerholen:</label> <div class="col-sm-8"> <input type="password" class="form-control" id="txtConfirmPassword" name="txtConfirmPassword" onChange="checkPasswordMatch();" placeholder="hier bitte das Passwort wiederholen" required> </div> </div> <div class="form-group"> <div class="col-sm-offset-4 col-sm-8"> <div class="registrationFormAlert" id="divCheckPasswordMatch"></div> <button id="password_submit" type="submit" class="btn btn-primary pull-right">Absenden</button> </div> </div> </form>
  23. uhhh a little bit old but still a problem for me..... i have created a form for the password. The form has a password field and a password confirm field. <form method="post" action="./" class="form-horizontal mgt-30px"> <div class="form-group"> <label for="txtNewPassword" class="col-sm-4 control-label">Neues Passwort:</label> <div class="col-sm-8"> <input type="password" class="form-control" id="txtNewPassword" onChange="checkPasswordRegEx();" placeholder="hier bitte das neue Passwort eintragen" required> <div class="registrationFormAlert" id="divCheckRegEx"></div> </div> </div> <div class="form-group"> <label for="txtConfirmPassword" class="col-sm-4 control-label">Passwort widerholen:</label> <div class="col-sm-8"> <input type="password" class="form-control" id="txtConfirmPassword" onChange="checkPasswordMatch();" placeholder="hier bitte das Passwort wiederholen" required> </div> </div> <div class="form-group"> <div class="col-sm-offset-4 col-sm-8"> <div class="registrationFormAlert" id="divCheckPasswordMatch"></div> <button id="password_submit" type="submit" class="btn btn-primary pull-right">Absenden</button> </div> </div> </form> It's made with bootsrap syntax. For testing i created a form submit <?php if (isset($_POST["submit"])) { $user = wire('users')->get('user'); $user->setOutputFormatting(false); $user->set('pass', 'Vah3eg'); $user->save('pass'); echo "Passwort wurde geändert!"; } ?> What i'm doing wrong? When i submit the form nothings happens. The startpage is loading.
  24. Thank you very much!!! it works when i'am inside the posts. It does'nt show up in the overview, but that is not important for now. As others said before, thank you for this wonderfull blog module! And thank you very much for your fast help!
×
×
  • Create New...