Jump to content

louisstephens

Members
  • Posts

    516
  • Joined

  • Last visited

Everything posted by louisstephens

  1. That worked great @AndZyk! I appreciate the help. Now for a dumb question, once redirected, success="true" (in laments terms), notification displays, is there a way to remove the ?alert=success from the url ? As it stands, I have a script that refreshes the page every so often to get any new changes that might have been made on the site, and currently the alert will just keep posting. There probably a better way to handle the refresh as well like ajax, but I dont quite know how to tackle that. I guess this was just an impromtu way of doing things.
  2. Thanks AndZyk . I will definitely give this a shot and see where this takes me. I completely forgot about GET (and I am still learning). Ill let you know how it goes. As for CSRF, that is a great idea. This is largely an internal site, but I will definitely take the precaution.
  3. I hope this is the correct place to post this. I currently am building a "dashboard" that displays some stats etc, but also handles login/logout with a form. Currently, when a user uses the form on the homepage, they redirected (if the credentials are correct) to the backend of processwire. However, I was hoping to direct the user back to the dashboard and display an alert (for now until I get a library to handle this). I got it somewhat working if I dont redirect the user. However, if I refresh the page, the alert still "pops up". Does anyone know of a way to redirect to the home page, but then display an alert? My Code to login: <?php if($input->post->user && $input->post->pass) { $user = $sanitizer->username($input->post->user); $pass = $input->post->pass; if($session->login($user, $pass)) { // login successful $session->redirect($dash); } } ?>
  4. You could make use of the repeater field to achieve this. You simply create the repeater and assign it the fields in questions, and the customer could add them quite easily. https://processwire.com/api/fieldtypes/repeaters/ Example <?php foreach($page->articles as $article) { echo $article->some_field; } ?>
  5. Thanks abdus! I guess I was unclear of how to add to the find() in processwire. However, knowing this now, this really helps me condense a lot of my code that I have already written. My head was starting to spin trying to figure out ways (sometimes it was a roller coaster) to deal with my foreachs.
  6. Thank you everyone for all the help! Is something like this possible, or am I reaching ? (sorry, still trying to learn my way through php and some things are still a bit intimidating) $ads = wire('pages')->find("parent.template=manufacturer, $today < expiration_date && expiration_date-432000 > $today, sort=expiration_date");
  7. Ah, thanks @flydev for catching my typo. I guess because it is in a "foreach", it just keeps counting so I get "1 2 3..." . I guess I didnt know how to handle putting the if outside the foreach since I dont know how to access $ad->expiration_date. Is there a better way of doing this? Edit** : Just moved echoing the $alert outside the foreach which gave me the count. However, if anyone had a better solution I welcome it. I seem to be using 3 foreach loops with an if inside each one just to accomplish this (so I can wrap a div column around them.).
  8. So I have a bit of code for ad management : <?php $ads = $pages->find("parent.template=client, sort=expiration_date"); $alert_count = 0; foreach ($ads as $ad) { $todaysdate = date("F j, Y H:i"); $today = strtotime($todaysdate); $expireson = $ad->expiration_date; $expires = strtotime($expireson); $fiveaway = $expires - 432000; if ($today > $expires) { $alert = $alert_count=+1; echo $alert; } } //end FOREACH ?> It currently finds all the pages with a parent of "client" and then I can drill down to the pages that have "Expired" in my if statement. I wanted to get a "count" of the pages that met the if statement requirements so I could output that number in an alert at the top of the page. When it runs, it currently just prints out "1 1 1 1..." and not the total count of pages. Does anyone know of a way possibly achieving my desired output? I tried count(), but that did not quite produce my desired output. I should note that I have several other if statements dealing with the date/time for outputting other alerts as well (just didn't think they were needed for this case).
  9. Would something like this work: working on it.... However, using "template=settings" should work for you. Are you using Tracey debugger as well? I find a lot of times this helps me spot an issue with my loops etc. https://modules.processwire.com/modules/tracy-debugger/
  10. It was DaveP and the post was At first I couldn't "like" the post, and I received the message in regards to reputation. After a while, I was able to hit "like".
  11. I guess this is the right place to post this. Just this morning I went to like an answer someone had given, and was met with a popup stating: "Unable to give reputation to this user". Has anyone encountered this before, or is there some "cap" on users with a certain ratio (reputation to posts) that is keeping me from providing reputation. It was not a big deal, but I wanted to give credit to where credit was due.
  12. You could achieve this by using a repeater with the url field in it. https://processwire.com/api/fieldtypes/repeaters/ Once you have that set up you do something like: <?php foreach($page->url_repeater as $url) { echo "<a href=\"{$url->url_field}\">" . "{$url->url_field}" . "</a>"; } ?>
  13. From what I understand, files are saved in page-specific folder (which is why the folder name is the page id). With that, I dont think it is an easy tweak, but someone please correct me if I am wrong. I did find a similar thread here :
  14. Have you tried padloper for processwire? I have not used it yet, but it looks very promising, and would probably cut down on trying to make magento work with processwire. https://www.padloper.pw
  15. My apologies on that. I should have picked up on the function reference.
  16. Also there is this:
  17. Couldn't you do something like: <?php foreach ($page->date_repeater as $date) { #code... } ?> This also has some examples of repeaters being used:
  18. I dont know if this is exactly what you are after, but here is a discussion regarding SSL. I have not done it myself, but it appears you can uncomment something in your .htaccess file .
  19. Hmm, Ill check on that, though I did add namespace Processwire; , though I take a deeper look.
  20. Thanks @kongondo, I was using: public function init() { spl_autoload_register(array($this, 'loadingMyFiles')); } private function loadingMyFiles($class_name){ include (__DIR__ . "/{$class_name}.php"); } I should have included that earlier. I am probably missing something important/small here. I tweaked mine to resemble what you had, but I am still getting /ProcessWire\ in the string. The file(s) I am trying to load are in a folder within the module file.
  21. So I was working on a module and trying to include a library (so I could use it across the site) using $modules->get('myModule'); . However, When I go to include the library folder (modeled after the LibFlourish module created some time ago). I keep getting: site/modules/MyModule/libraryName/ProcessWire\filetoinclude.php This comes with an error notifying that "failed to open stream: No such file or directory in ...".. Is ProcessWire supposed to be in the include url, or is there a way around this? Sorry, I am quite new to working with my own modules. I just noticed the sub forum regarding Development, if someone could move this to the correct area I would appreciate it.
  22. I wasn't quite sure where to post this, as this is a question regarding the module (sorry if it is in the wrong place). I was wondering if anyone has used the Email to Page module and figured out a way to "move" incoming css to another field, or how to render the css so the message just renders utilizing the css. Right now all of the message contents get dropped into a textarea field and display in a template as a jumbled mess. Perhaps I am missing a formatting option in the text area field to render the css and html.
  23. I spoke too soon, I got bogged down. I notice that findOne() only finds one (obviously, unless I am missing something), and returns the same id each time. Is there a way to compare the form entry amongst all of the entries that have been created?
  24. Thanks everyone for the help. With all the suggestions and a few references, I was able to get it all working, event though I always seem to miss one key thing in the API documentation.
  25. I have a bit of a head scratcher for myself. I have a form (first name, last name, and domain) that I use to create pages. I have the first name and last name being combined and saving as the title, and being saved in their individual fields as well. The domain name is just being saved in it's designated field under the page. This all works quite well in fact. (just a note: for a special case, I am combining all three values so it looks like johndoe@domainselected.com) However, I thought I might need to check to see if the page already existed, and if it does, provide the user with an error. If it doesn't already exist, follow through with creating the page. I didnt want to save the entire address in the title as I knew "@" wouldn't fly with the url to the page. I thought I could use a foreach, but I understand that outputs an array, when I need to check just one entry. Does anyone have any suggestions? I am probably making this much more difficult than it needs to be. I have fixed the issue... "==" seemed to fix it.
×
×
  • Create New...