Jump to content

fbg13

Members
  • Posts

    344
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by fbg13

  1. That is up to you. I suggest you this tutorial to understand pages, fields and templates.
  2. It's not the logged in user but the current user, if user is not logged in then it represents the guest user. @Thor Say the profile page has only the code below. // if user in not logged in redirect to login page if(!$user->isLoggedin()) { // redirect code } echo $user->name; If you visit the page, just /profile/ (no user id, no user name), it shows your name, if another user visits the page he sees his name, not yours.
  3. @Thor Don't know how you came to that conclusion. You said you want to have a profile page for users to see and edit their information. So you make that page accessible only to logged in users, once a user is logged in he sees his information. That information comes from the $user variable that holds the data of the logged in user ($user->name, $user->email, $user->your_custom_field etc). If you want users to see other users profiles you can do that too. You can enable url segments and the url segment is the username. Then in your template you get the information of an user like this: // don't use $user or you'll overwrite the PW $user variable $u = $pages->get("template=user, name={$input->urlSegment1}"); // or $u = $users->get($input->urlSegment1); // and get info about the user $u->name; $u->email; // change user info $u->of(false); // http://cheatsheet.processwire.com/page/built-in-methods-reference/page-setoutputformatting-true-false/ $u->name = "whatever"; $u->save();
  4. https://processwire.com/api/ref/user/
  5. You have two different divs displaying that info, one for large screens and one for small screens, that's why they are different. You can resize your browser window and see it change.
  6. http://php.net/manual/ro/language.namespaces.rationale.php So by using the variable you would have no need for the namespace, depending on what else is in your file.
  7. I think something along the lines "All the files related to the site are organized in this directory." might be better, since the "files that will contain the site logic" actually are in the templates directory and there are other directories in /site also. Haven't read it all but looks very thorough. Good job. Edit: Appreciate it, but there was nothing worth of a special thanks.
  8. Does it remember the widths on a refresh or on a new session?
  9. Had this written before Macrura's post so I'll leave it here. $x = 0; foreach($recipes as $recipe){ $class = "class"; $imageSrc = $recipe->image->first()->size(200,200)->url; if($x == 1){ $class = "otherClass"; $imageSrc = $recipe->image->first()->size(500,200)->url; } echo "<div class='{$class}'><img src='{$imageSrc}'></div>"; $x++; } You can also use css :nth-child pseudo class
  10. There are some threads regarding this subject, but i just can't find them anymore. Can someone help me out?
  11. Seems to be caused by the divider, hiding them fixes the problem.
  12. Thank you @kixe I managed to achieve what I need. Any idea what the key (pw300/pw200) is doing? For whoever is interested. In my module I added public function init() { wire()->addHookBefore("ProcessModule::execute", $this, "changeModuleService"); } public function changeModuleService(HookEvent $event) { if($_GET["update"] === "ModuleName") { wire("config")->moduleServiceURL = "http://domain.tld/"; wire("config")->moduleServiceKey = (__NAMESPACE__ ? "pw300" : "pw280"); } } And the module autoload property is set to "autoload" => "path=/admin/module/" Now whenever the "check for updates" link is clicked it searches for a new version on domain.tld/ModuleName, this has to return a json similar to the one posted above.
  13. @kixe Won't changing those options affect other modules from the directory?
  14. I mean going to the module page and clicking the check for updates link and having a download and update button if there's a new version. https://gfycat.com/DiligentRichAlaskanmalamute
  15. Is it possible to update a module without it being in the module directory? The same way that one in the module directory is.
  16. You can always change the password through the api <?php $u = $pages->get(...); $u->of(false); $u->pass = "..."; $u->save(); Also we are off topic here.
  17. @modifiedcontent Works the same as everywhere else, you have a form, form gets submitted, you process it (do what you need with the values submitted). I showed you how to save the values in a page, the same way you can create a user. <?php // $input->post->username same as $_POST["username"] if($input->post->submit) { $u = new User(); $u->name = $input->post->username; $u->email = $input->post->email; $u->pass = $input->post->password; $u->registrationDate = time(); $u->addRole("member"); $u->save(); }
  18. @ridgedale 1. check the URLs tab 2. you might be using delayed output, the template files are used to set some variables which are later echoed in another file included at the end of the template file Something like this <?php $header = "<header>...</header>"; $content = "<div class='content'><h1>{$page->title}</h1><div>{$page->content}</div></div>"; $footer = "<footer>...</footer>"; // echoing something here will display above the header include ("main.php"); The main.php file <?php // here we echo the variables set in the template file echo "<html><body>..."; echo $header; echo $content; echo $footer; echo "</body></html>"; 3. $stories = $page->children("limit=6, sort=-date"); the above takes the 6 latest child pages of the current page, so on pages using the news-index.php template it gets the 6 latest child pages . https://processwire.com/docs/tutorials/
  19. @modifiedcontent Say you have the following form <form method="post"> <input type="text" name="name"> <input type="textarea" name="message"> <input type="submit" name="submit"> </form> You can save it to a page like this <?php if($input->post->submit) { $p = new Page(); $p->template = "template_to_save_form"; $p->parent = $pages->get("/parent-page/"); $p->title = $input->post->name . " - " . date("Y-m-d"); $p->submitted_by = $input->post->name; $p->message = $input->post->message; $p->save(); } You'll have to create the template, its fields and the parent page first. Also before saving the page make sure to validate/sanitize the input. <?php $p->submitted_by = $sanitizer->text($input->post->name); // instead of just $p->submitted_by = $input->post->name; https://processwire.com/api/ref/sanitizer/
  20. <?php $x = 0; foreach($page->SlideImagesRepeater as $SlideImagesRepeat) : $class = ($x === 0) ? "active" : ""; ?> <div class="item <?= $class ?>"> rest of code </div> <?php $x++; endforeach; ?> http://php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary
  21. @Reezal AQ try $SlideImagesRepeat->Sliders->first()->url
  22. How will this be better than the current Markup Regions?
  23. Maybe it's this https://en.wikipedia.org/wiki/Year_2038_problem
  24. @MilenKo Ryan's example include("./MyCommentForm.php"); $form = new MyCommentForm($page, $page->comments); echo $form->render(); is for extending the class inside /wire/modules/Fieldtype/FieldtypeComments/CommentForm.php with your own inside MyCommentForm.php and changing the necessary methods to suit your needs.
×
×
  • Create New...