-
Posts
11,180 -
Joined
-
Last visited
-
Days Won
372
Everything posted by adrian
-
Right after install script: "Database unavailable."
adrian replied to johnstephens's topic in Getting Started
Hi @johnstephens and welcome to PW. Sorry your first experience has been less than stellar. That error seems a little strange given everything else you have described, but if you can access the homepage, then obviously PW is being able to connect to the database to get that content. Typically if you can access the homepage, but no other pages, including the admin it is a mod rewrite issue. Have you tried uncommenting the first of the RewriteBase options in the .htaccess file - around line#103? -
Call to a member function first() on a non-object
adrian replied to bwakad's topic in API & Templates
In the docs for this module it says: In the location where you want to output your map, place the following in your template file: $map = $modules->get('MarkupGoogleMap'); echo $map->render($page, 'map'); You are using $Location there which is a string "$Lat, $Lon" based on your definition of it. It needs to be a page object. When you are getting errors like this, it is sometime best to start with the default code from the docs before experimenting with other approaches, like parsing xml. Stick with the basics. Once you have those grasped, the rest will be easier to sort out and we'll continue to help/ -
Currently this isn't possible by default, but I like the idea of not having to populate address fields in two places. I have taken the other approach and parsed the address from the map's address field into the components I want for displaying on the site, but this has problems depending on how the address was entered if it's not consistent. Thinking quickly, you could hook into page save and grab the contents of those address fields and use them to populate the map's address field. The problem is that the geocoding happens on blur of the address field, so that would need to be triggered in some other way in your module. Something to think about anyway.
-
I agree with Joss - separate fields sound like a much better solution!
-
I think it is likely this line: $audiofiles = $audio->audio->filename; Try it with just: $audiofiles = $audio->audio; You need to keep that audio field as an array, rather than getting its filename at that point.
-
Looks pretty cool diogo. One small thing - in the recursive call of the function, you are using findPages, instead of myFindPages
-
Retrieve The Type of A Field From Inside A Module
adrian replied to bytesource's topic in Module/Plugin Development
All you need is: if($fields->get("fieldUsingTextile")->type == "FieldtypeText"){ I haven't played with textile, but I am curious why a plain text field would have paragraph tags in the first place. Are they coming from textile, or are they being pasted in and not stripped, as they would be in a normal plain text field? -
To be honest, and no offense intended to the author of that module, but I don't believe it is really stable yet and unfortunately he hasn't been responsive to fixing some of the issues. The other issue is that it includes a lot of fields that you may not use. I think you'd be much better off creating your own system for front-end user management - it is very easy. This post from Ryan should get you started: https://processwire.com/talk/topic/1716-integrating-a-member-visitor-login-form/?p=15919
- 30 replies
-
- 2
-
-
- Drupal
- get started
-
(and 1 more)
Tagged with:
-
The API handles all the CRUD operations. eg, to create a new page: $np = new Page(); $np->parent = $pages->get("/about/"); $np->template = "basic-page"; $np->title = "New Page"; $np->of(false); $np->save(); Take a look at the API cheatsheet: http://cheatsheet.processwire.com/
- 30 replies
-
- 3
-
-
- Drupal
- get started
-
(and 1 more)
Tagged with:
-
I obviously need to read up on ElasticSearch some more, but this sounds pretty cool - thanks!
-
You can pass variable via render like: echo $pages->get($child->id)->render(array('mobile' => $mobile)); and then in the template use $options['mobile'] to get the value.
-
You should have a good read of this thread: https://processwire.com/talk/topic/992-problem-with-assetsfiles-folder/
-
Autload module not discovered by wire('ModuleName')
adrian replied to Gazley's topic in General Support
I know this is a post that Soma started on this topic, but I still think it is relevant to link to here since we got into talking about checking to see if a module is loaded or not: https://processwire.com/talk/topic/5477-check-if-a-module-is-loaded/ -
If the allowable child template settings for the destination page tree allow it, then there should be no reason you can't move the page, so it sounds like that might be what's stopping you. What does the permission error say?
-
Hey Ryan, Just a quick note about the new 1 step page adding. It seems to have some weird effects if you create the page via the API. Doing this: $p = new Page(); $p->template = "basic-page"; $p->parent = $pages->get("/about/"); $p->save(); resulted in two new pages which is weird: untitled untitled-4 and even weirder, this was on a fresh install so for one not sure why it jumped to 4 for the second one. The other problem is that because you need to save the page to create it at all via the API, the name is actually populated with "untitled" already, which means that if someone then goes to edit the title, it won't automatically set the name to match. If I add $p->status = 2561; to the above code then the new page is created with the new temporary status setting which is great - the name is not populated so things work as expected. The only problem now, is that there are still two new pages created. I know this feature was not really designed for API adding of pages, but I can still see people using it that way, unintentionally or maybe even intentionally. Another more important side effect I just discovered - if you create the page with no status setting, but with just a title (no name), like this: $p = new Page(); $p->template = "basic-page"; $p->parent = $pages->get("/about/"); $p->title = 'TestMe'; $p->save(); then two pages are still created. The titles are correct, but the names are: untitled-n. I think this could be quite problematic for some existing modules and chunks of template code that rely on automatic name generation from the title. If you set the name as well, then all is good again - one page created with everything named correctly. EDIT: OK, I am going to crawl back in my hole now - I was running these tests with Hanna Code's test functionality - I have been using it for a while now as an easy way to test code snippets. Turns out the double issue was all because of Hanna. I re-ran these tests using my Code Tester module (which I used to use all the time) and everything seems to work as expected. The $p->status = 2561; was still obviously key to making things work as expected though. Feel free to unlike this post now EDIT2: Actually, I think there is still one potential issue - I still seem to be having the issue that a newly created page that is assigned a title but not a name ends up with "untitled" as the name. Does anyone else see this?
-
This is sounding even cooler now While you are on a roll, any thought about having an option to generate the name and the title from more than one other field. Like being able to concatenate first_name and last_name fields. I am thinking it would be great to be able to set the title to locked (visible but not editable) for the specific template. And once the page is saved, it (name and title) will be populated from the first_name and last_name fields. Would that be much more work?
-
This is mostly stolen from Ryan: https://processwire.com/talk/topic/1716-integrating-a-member-visitor-login-form/?p=15919 But it adds the functionality to redirect back to the page the user was on when they started the login: $requested_pid = (int) $input->get->pid; $t = $pages->get($requested_pid)->path; if($user->isLoggedin()){ if($requested_pid == ''){ $session->redirect('/'); } else{ $session->redirect($t); } } if($input->post->username && $input->post->pass) { $username = $sanitizer->username($input->post->username); $pass = $input->post->pass; $u = $users->get($username); if($u->id && $u->tmp_pass && $u->tmp_pass === $pass) { // user logging in with tmp_pass, so change it to be their real pass $u->of(false); $u->pass = $u->tmp_pass; $u->save(); $u->of(true); } $u = $session->login($username, $pass); if($u) { // user is logged in, get rid of tmp_pass $u->of(false); $tmp_pass = $u->tmp_pass; $u->tmp_pass = ''; $u->save(); // now redirect to the profile edit page if($tmp_pass == $pass){ $session->redirect('/profile/'); } else{ $session->redirect($t); } } } // present the login form $headline = $input->post->username ? "Login failed" : "Please login"; echo " <h2>$headline</h2> <form action='./?pid=".$requested_pid."' method='post'> <p> <label>Username <input type='text' name='username'></label> <label>Password <input type='password' name='pass'></label> </p> <input class='bluebutton' type='submit' name='login' value='Login'> </form><hr /><br /> <p><a href='/reset-pass/'>Forgot Password?</a></p> "; Keep in mind that this also includes "forgot password" functionality, but doesn't include all the code for that - take a look at that post of Ryan's to get the rest.
-
What is your username? If you log $username with both different sanitizer options, is it the same? Do you have debug set to true? Are there any other php errors? Anything in the PW assets/logs/errors.txt file?
-
I am not sure why you are ending up with the numerical character reference in there. Does it appear that way in the HTML of the mail subject field, or not until it is actually sent? Are you using one of the new custom email modules, or the built-in one? Can you try to figure out exactly when it is being converted? When you view the source, are you seeing ' or just ' There are functions out there to decode NCRs, but it is overkill for your needs and also I think it would be better to figure out why/where it's happening in the first place. If you can't manage to figure out the cause and you're in a rush, you could just do a str_replace in your email script to put it back to a single quote.
-
Is the page completely blank? It sounds like you have a PHP fatal error which is a code issue, rather than a login attempts issue. What happens if you remove that code you just added - can you login again, does the error go away?
-
Isn't that what Joss linked to above: https://processwire.com/talk/topic/5869-forgotten-password-on-the-front-end/ There is also this solution which I use all the time: https://processwire.com/talk/topic/1716-integrating-a-member-visitor-login-form/?p=15919 Hope that helps.
-
I submitted a pull request for similar functionality. It copies the cropped images to a separate images field. I put this together very early in my experience with PW and I know that antti wanted an option to opt in or out of this feature which is why he hasn't accepted it. It would be easy to modify to make it optional, but perhaps you can make use of my code anyways: https://github.com/adrianbj/Thumbnails/commit/c3539ada4306acd7f98c667864aa5ebe1fd0a244
-
I have used that PW comments reply version and it works quite nicely. Along with the comments manager module (http://modules.processwire.com/modules/process-latest-comments/) it works out to be pretty powerful. I guess the one thing we are missing is a comment rating/like system.
-
CafePress or Zazzle might be lower risk than ordering ahead, but probably not as much profit?
-
This is how I have done it in the past: "id!=2, id!=7, has_parent!=2, has_parent!=7, template!=admin, sort=id, include=all" Soma suggested (https://processwire.com/talk/topic/4530-how-to-get-a-list-of-all-pages-recursiv-without-admin-pages/?p=44508): "has_parent!=2,id!=2|7,status<".Page::statusTrash.",include=all" Ryan suggested (https://processwire.com/talk/topic/4530-how-to-get-a-list-of-all-pages-recursiv-without-admin-pages/?p=44782): "template!=admin, has_parent!=2, include=all" Those should help you with the getting of all pages. From there, getting pages fields is simple enough. Not sure about the memory usage issues - maybe you can test and see how it goes
- 1 reply
-
- 3
-