Leaderboard
Popular Content
Showing content with the highest reputation on 09/13/2012 in all areas
-
For everyone new to javascript/jQuery i thought i'd post a link to what is imo a great intro: http://jqfundamentals.com/ (Maybe we could use this topic to post more references; CSS, PHP etc.)3 points
-
I would first check if the username/email isn't already taken. If it is not taken continue with creating a new user. public function check_username($username) { $u = $users->get("email=$username"); if($u->id) { return "Already taken!"; } else { $nu = new User(); $nu->name = $username; $nu->save(); //continue with the new user and further code } Dammit! You gotta be quick on this forum! Pete beat me to it.2 points
-
You don't want this then as that creates a new user object before you've even checked for the duplicate user: $users = new User(); You need to skip that line and check it first like this: public function check_username($username){ $u = wire('users')->get("email=$username"); if($u->id) { return "Already taken!"; } else { // Then add your code to add the new user here, something like: $user = new User(); $user->name = $username; $user->save(); } }2 points
-
No problem, Study the docs section; maybe do the Small Project Walkthrough and just read through the code in the files of the templates dir. They are well commented and you really see what's going on. When you become more comfortable with some basic PHP + ProcessWire's API it's time to have the cheatsheet standby. You'll be flying in no time.2 points
-
It's important to remember that in ProcessWire a Template and a template fileare two separate things. In Setup->Templates you create and manage Templates. You can add fields to a template, do some access settings etc. The fields you add to the template are shown in the admin when you create a new page with that template. The order in which they appear is controlled by the template settings (drag and drop). A template most of the times has a template file associated with it, but it isn't necessary. In a template file you have complete control over the output and logic. If you have no need for a sidebar field at all you could go to Setup->Fields and remove the 'sidebar' field. (ofcourse, you then probably would want to remove references to that field in your template codes.2 points
-
Sorry for the excuses that are annoying after that period of time. BUT: It is not abandoned, it was rather postponed because of a lot of work, holidays and moving to a new office. I use the dashboard already in several projects, but have to clean out a lot of things before going public. Already talked to Ryan because of a potential core change I believed was necessary, but turned out it isn't. Give me at least 'til the end of september and I will release something. More or less polished, promised! (will be my first release, so I want it to be good ;-) )2 points
-
i.am first you can puut this in your head.inc tamplate or some includeded file before.u are doing $page->url $pages->addHookAfter('Page::path', null, 'hookPagePath'); function hookPagePath(HookEvent $e) { $page = $e->object; if($page->template == 'article') $e->return = "/blog/$page->name/"; }2 points
-
Sure! Mike over at CMSCritic is a good guy and I'd support anything he's doing over there. I'd encourage anyone that wants to vote for ProcessWire in any of those categories to please do so! I know I will. My experience is these guys are pretty hard to get through to. I've personally talked to Eric Meyer and Jeremy Keith about ProcessWire and gave them a card with the URL on it. Even had lunch with Eric Meyer (he sat down next to me at an AEA event), and he's about the nicest person I've met. But I think he was relieved to talk about family and kids rather than webdev. These guys get hounded with everyone they meet telling them about their project, and it's pretty much all noise to them (as most of it probably should be). The mention of a "CMS" is especially noisy, as nearly every developer has dabbled into making their own CMS at one time or another. I'd venture to guess these guys hear about some new CMS almost every day. They make a genuine effort to act interested, but they really aren't. They need to hear about something many times, or from one they know really well, before they will take the time to investigate. Ultimately I'm just interested in making sure ProcessWire is the best tool of its kind. Whether its "known" or not is beside the point. Granted, I'd like to share it with as many people that will benefit from it as possible, but would rather let folks find it at their own pace. I think ProcessWire is a real competitive advantage for many (at least is for me), enabling us to get things done quicker and at less cost. So if everyone was using it, it'd be harder for me to get work.2 points
-
Hi there. First of all, thank you for all of your work on ProcessWire, it is truly an amazing piece of work. I can't imagine developing on anything else anymore... I am having a bit of trouble uploading images through the API. I want users of the site to be able to upload images into their page. Here is the code that I have: Get the page that belongs to that user: $l = $pages->find("user_account={$user}, template=listing")->first(); Then this is the code that I am using to upload the image: if ($input->post("imagesend") == "1") { $l->setOutputFormatting(false); // instantiate the class and give it the name of the HTML field $u = new WireUpload('userfile'); // tell it to only accept 1 file $u->setMaxFiles(1); // tell it to rename rather than overwrite existing files $u->setOverwrite(false); // have it put the files in their final destination. this should be okay since // the WireUpload class will only create PW compatible filenames $u->setDestinationPath($l->files->path); // tell it what extensions to expect $u->setValidExtensions(array('jpg', 'jpeg', 'gif', 'png')); // execute() returns an array, so we'll foreach() it even though only 1 file foreach($u->execute() as $filename) $l->files->add($filename); // save the page $page->save(); } The error that I am getting is: Exception: You must set the destination path for WireUpload before executing it Any ideas? Thanks!1 point
-
It's not attributes for fields, but more html attributes on the inputfield render output. As you say correctly it's not something saved with the inputfield.1 point
-
Might have just found it: the getVariations() function in /wire/core/Pageimage.php calls setFilename() with a non-normalized path from DirectoryIterator. Though still not clear why the $file->getPathname() from DirectoryIterator would be returning a file in the format with both types of slashes (/path/to/file\file.jpg). But that bit of code in Pageimage.php is a problem either way, as it doesn't consider the slashes and it needs to. Luckily an easy fix.1 point
-
Thanks Steve. We normalize to forward '/' slashes internally, and I normalize them as soon as anything comes from the OS (see /wire/core/Paths.php). I don't think that function is involved in this particular case, but like you pointed out, that function does assume it's dealing with paths in an expected format that have already been normalized. The setFilename() function also assumes it's dealing with filenames in an expected format, so that extra slash must be finding its way in there before the function call. What I'm looking for is any native PHP that would return a path, like a DirectoryIterator loop where maybe I'm doing something like in that function you pointed out -- a trim($dir, '/') rather than a trim($dir, DIRECTORY_SEPARATOR). So far I haven't found it, but the hunt is on.1 point
-
1 point
-
joe_g or DaveP -- can you try replacing your /wire/core/Pagefile.php with the file attached, and let me know if it corrects the issue? Pagefile.php Thanks, Ryan1 point
-
WillyC's solution is a good way to go if you have this need. But want to mention that the whole idea of multiple routes to a page kind of goes against the grain of the ProcessWire philosophy. By design, there is only one URL to any given page. This is different from systems that disconnect their data from URLs (Drupal, EE, etc.). ProcessWire considers pages like files on a file system. We are trying to embrace the way that the web is addressed rather than counter it. I understand the desire to make a shorter URL for a given page, and that's a fine reason to implement a solution like this (and I've done it myself too). But the reason you don't see things like this outlined in the documentation is because I don't think it's a best practice, whether in ProcessWire or on the web in general. So if someone uses multiple routes, I would suggest it only to solve a specific need after a site is produced… not as something to build around from the start.1 point
-
Thank you for the offer! I figured I could code the back-end of this thing pretty easily once Form Builder has page publishing ability. But I'm still about 2 weeks away from that. If you or anyone else wants to handle the design and/or markup, that would be great, and help to get this moving forward more quickly. Also might be good to look at processwire.net as the wrapper template since it'll be coming into play very soon.1 point
-
You want to check after some kind of form submission? Not sure but something like this? $u = $users->get("email=$email"); if($u->id) { echo "Already taken!"; }1 point
-
Finally comitted the fix to Git! I hope to make some other improvements in the next few weeks. By the way, I found a stupid mistake. You were not supposed to see the "Google Analytics Account Id" in the module config, unless already chosen from the Dropdown. It's clear that people get confused when this setting exists right after the install... Check this code out: //Ga Account ID - only display when Account was chosen with dropdown before $field = ($data['accountId']) ? $modules->get("InputfieldText") : $modules->get("InputfieldHidden"); $field = $modules->get("InputfieldText"); Aaaaaaaaaaargh :-1 point
-
Thanks Ryan, Not sure what I was thinking this morning — thinking too much about the iPhone 5 I guess.1 point
-
Have a look at the code in the file head.inc that is in the templates directory: <div class='sidebar_item'> <?php // if the current page has a populated 'sidebar' field, then print it, // otherwise print the sidebar from the homepage if($page->sidebar) echo $page->sidebar; else echo $homepage->sidebar; ?> </div> </div><!--/sidebar--> head.inc is included by the basic-page.php template file. <?php /** * Page template * */ include("./head.inc"); echo $page->body; include("./foot.inc"); You can: a) copy and paste the contents of head.inc into a new file. Delete the sidebar code i showed above and save it to head_noside.inc or whatever you like. Afer that change basic-page.php contents to include("./head_noside.inc"); Be aware, keep the other code in there the same. b) Make some logic in head.inc to not output the sidebar if the page template is basic-page.php. c) alot of other options1 point
-
Thanks for that Ryan! The goal with these awards is to help spread the word on both lesser known systems and systems that don't just win by playing the numbers game and having their huge communities vote like mad. I have been very vocal about my disappointment with Packt's awards and decided to get out own going. This is our first year and I've already lined up financial sponsors for next year so we can fork out some pretty amazing cash prizes. Plus, you can win a Nexus 7 by voting or nominating so why not take two seconds and jump in? best of luck to Processwire!1 point
-
Thank you! I followed this exactly and I get the multilingual works at the new website. Too happy that I have to share...1 point
-
I've been reading about ProcessWire off and on for the past couple of months to see if it's right for me or if I should stick with WordPress. I'm still trying to wrap my head around some of the concepts; I'm not a programmer, but I am eager to learn. There are things I like about both systems, but I keep coming back to ProcessWire's way of doing things every time I read a WordPress tutorial. So after lurking on the forums for a while, I'd like to say hello. The community here seems very helpful and kind to newbies. I've had to read some of the forum posts four times before I understand them, so I'll probably ask some dumb questions, but you all come across as a very patient bunch. I look forward to learning from you. - Tim1 point
-
Yeah, it's alright I suppose @ryan - thanks for this as it's perfect timing for a few things I'm intending to do too1 point
-
ProcessWire doesn't allow direct execution of PHP files in its /site/templates/ directory for security. So what you'd want to do is place your ajax PHP file somewhere else, like in the site root or under some other directory that you've created. Then include ProcessWire's /index.php to bootstrap it: /somefile.php <?php include('./index.php'); // bootstrap ProcessWire if(wire('config')->ajax) echo json_encode("Hello"); When you bootstrap ProcessWire, it'll work the same as it would from your template file, except that you have to access the API variables through the wire() function, i.e. wire('pages'), wire('config'), etc. More here: http://processwire.com/api/include/1 point