Jump to content

ryan

Administrators
  • Posts

    17,308
  • Joined

  • Days Won

    1,725

Everything posted by ryan

  1. Adam, Have you set $debug = true in /site/config.php? Though the error message you reported is fairly specific, so I'm not sure it's going to get any better than that. What you may want to do is try putting a test file on the server in the web root and then loading it from your browser. I'm guessing it'll report the same problem, but running this test at least allows us to rule out some things. Let me know what it does. /test.php <pre> <?php error_reporting(E_ALL); ini_set("display_errors", 1); $target = "./site/assets/files/1/test.php"; copy("./test.php", $target); if(is_file($target)) { echo "\nfile was copied"; unlink($target); } else { echo "\nfile was not copied -- what error message did you get?"; }
  2. If anyone wants to take the lead on building this functionality, I'll be glad to collaborate with you on making it a ProcessWire module. Based on what Deandre212 posted, I am thinking it might involve a Page::render hook that looks for certain tags and adds attributes to them. Or, [possibly better] it might involve creating a new RDFa runtime TextFormatter module that you can assign to text fields like text, textarea and textarea-tinymce. For an example of an existing runtime text formatter, see any of the modules in here: /wire/modules/Textformatter/. While I know how the ProcessWire side would work, I don't really know how the RDFa side would work...
  3. Hi Ryan, Good to see you in the forums! This will make it into the main API documentation. I've been posting stuff here first, and then transitioning it to the main API docs after making sure I've accounted for everyone's questions, and haven't made any typos. Ryan
  4. Hi Adam, Didn't we find before that if one of the parent dirs lacked "x" permission for apache, that this could happen? I don't recall exactly, but it seems like there was something like that happening on one other person's hosting account. Do you have shell access? i.e. could you chmod -R og+rwx in /site/assets/ to test? Otherwise, I think you may be right about server quota or possibly something in the PHP settings. Have you looked at all file upload related settings in phpinfo? Ryan
  5. Includes are an important part of templates, and they are about as simple as it gets. When you do the include, I suggest you put a "./" in front of the filename, i.e. include("./header.inc"); Yes it'll probably work without the "./", but it will force PHP to search all of it's include paths. Whereas if you put a "./" in front of it, it will only check in your /site/templates/ dir (which is more likely what you want).
  6. Adam is right that you really are better off doing this in templates. But if you still have a specific need to do this, here's how you can. I would suggest setting up a field specifically for PHP code, and call it "phpcode" or something like that. Make it a standard textarea field, and disable any output formatting in the field's settings. In your template code, you will want to eval() the field's value, which will evaluate it as PHP. This is how other CMSs do it. It's not particularly safe or efficient, so be careful where you use it. if($page->phpcode) eval($page->phpcode); The reason I suggest using a field just for PHP code is that in a regular textarea field, you would want to have output formatting like entity encoding. You don't want that in a field that supports PHP, because it would break the PHP. So mixing bodycopy and PHP in the same field would not be a best practice (though you could certainly do it).
  7. Adam is right, and I'll expand on what he said. Things like RDFa and microformats are part of your markup. If you are wanting to support these, ProcessWire supports it. ProcessWire doesn't generate markup (except for a few helper plugins). Instead, it manages your content and lets you decide how you want to mark it up and output it. That is to say, it's already RDFa and microformats ready. However, you still have to decide when and where you want to mark up your content this way. While you could use TinyMCE, I think I'd want to do so with the support of a TinyMCE plugin. I'd want something foolproof that doesn't get me involved in the technical details of RDFa every time I add a page to my site. If that is also your need, I would structure your data semantically using fields in ProcessWire for data that you want to markup with RDFa attributes. Then take the semantic data from your page fields, and use RDFa attributes when you output your markup. This will work great for many instances. But it doesn't solve the need for contextual RDFa attributes that appear in content you've input into TinyMCE. I did a quick search for an RDFa plugin for TinyMCE and it sounds like there are people working on it, but nothing concrete (as far as I can tell). So for that type of RDFa support, we may have to wait till a rich text editor has proper support. Though that would put pretty much all CMSs in the same spot on that particular issue. I will keep an eye on this and do more research, as I do think this is an important thing. Thanks, Ryan
  8. Usually if I have hundreds of page references (categories) to create I use the API to create them (like from a CSV or text file) rather than doing it manually -- let me know if I can give an example of how to do that. If you are doing something with free tagging, then I would use url segments. Lets say you've got a free tagging field called "tags", and it's just a textarea with one or more tags. You might setup a template called "tags" and on a page called "/tags/". Accessing /tags/something/ in your browser should list all pages that match the tag "something". To do that, first turn on URL segments in your template (Admin > Setup > Templates > Advanced > URL Segments). Then, in your template, your code might look something like this: <?php if($tag = $sanitizer->selectorValue($input->urlSegment1)) { $matches = $pages->find("tags*=$tag"); echo $matches->render(); // or loop through and print on your own } For pre-defined categories using page referencs, I think that asmSelect is a good input field to use for selection. However, if you need to be able to select pages in a hierarchy (like category or subcategory with the same field) then I think the "page list select multiple" is a good solution, because it enables you to select pages in a hierarchy rather than in one level. You could also use any of the other multi select input fields and use the template as the base for selection rather than the parent. ProcessWire is a couple months old, and Drupal has been around since 2001, so we're not going to have the same level of features in some areas. But if you think Drupal is better at this than PW2, describe further, and more specifically, so that I can make sure we get PW2 one step ahead. When it comes to working with these kind of data relationships, I believe PW2 is better than Drupal on the back-end, so I want to make sure I provide enough front-end simplicity to provide and prove that. thanks, Ryan
  9. AdminBar is really great! I will be installing it on all of my clients' sites (already started actually). ;D
  10. You can get the admin URL from: $config->urls->admin Or if you want to retrieve the admin page: $admin = $pages->get($config->adminRootPageID); Btw, I don't often do it, but it is good security to change your admin page name. You do this by editing it, clicking on the 'settings' tab and changing the name.
  11. I think you would want to use the sitemap strategy, like on the API "include & bootstrap" page. But if you only need one level of depth, we could do it even simpler. I'm on an iPhone right now so don't have good examples, but let me know if the sitemap strategy doesn't make sense an I can post some good examples in the morning.
  12. Hi Martin, I think this is a good example: http://processwire.com/talk/index.php/topic,56.msg443.html#msg443 What we're doing there is hooking in before a page is rendered, and changing the template filename to one in the AdminBar modules directory. Let me know if this makes sense, or if I can provide another example? Thanks, Ryan
  13. Sure--what I would suggest is adding a text or textarea field and calling it "tags". Then people can type whatever tags in there that they want. When you want to find all pages matching a given tag, you'd do this: $matches = $pages->find("tag*=something"); // where 'something' is a tag If you want predefined tags, then I would use a page reference fieldtype to associate a group of pages as tags. Populate the pages with their name or title field as your tag. Then use a multiple selection field like asmSelect to allow selection of the tags/categories. To find pages matching a given tag, you'd do this: $tag = $pages->get("/tags/something/"); $matches = $pages->find("title=$tag");
  14. Sevarf: I forgot something on the previous commit (it wasn't allowing periods in the URL name). That is fixed, so if you grab the latest, it'll let you use ".html" with your page names (or any page name with periods in it for that matter). Regarding SEO and .html, of course listen to your expert. I don't claim to have the title of SEO expert, so take what I say with a grain of salt. But SEO is fundamentally intertwined with all the work I do, and has been for more than 10 years. I'm responsible for maintaining dozens of sites at top rankings with very competitive terms over the long term. My experience may be different from others, but what I've learned is that any time you are tweaking details with the intention of tricking (or optimizing) Google into thinking your page is something it's not, you are asking for trouble. It's arguable whether using an .html extension falls into that category since it can be purely stylistic. But your SEO expert is suggesting you do it in order to exploit some apparent weakness in Google's algorithm (which I don't believe exists). An SEO strategy that dips into these considerations it not a good long term strategy, and is focused on the wrong things, in my opinion. However, I don't claim to have all the answers, nor do I know anyone at Google, so I'm not suggesting you change your strategy. Just be wary of anything founded in quick fixes or algorithm exploits. Unless the need calls for black hat, in which case we'd probably be talking about how to use ProcessWire to automate creating thousands of Youtube and Facebook accounts. That will be a fun guide to write. Regarding this forum's use of .html -- SMF is not a good example. I love this forum software, but have a look at the SMF code sometime, and you'll see what I mean. In addition, view the source on this page and you'll see a populated meta keywords tag... they make a great forum, but I wouldn't trust them with my client's SEO. Though I do have to give them credit for adding a required, difficult-to-modify (hashed) backlink to their site in the footer. I had to use PHP's buffer functions just to change it to a rel=nofollow. Adam: I don't want a site-wide slash setting because template API code has to consider the slash setting. I want to have a site-wide expected default (of having a slash) so that there is a known playing field for code examples, prepared templates, etc. If someone wants to change it, then they can do so with the knowledge that they may have to consider it in their code on a template-by-template basis.
  15. I do want to make sure people have the flexibility to do it any way they want, so I think that's what we've got now (they can set it according to their preference). I've been meaning to add this slashes setting, so figured now was the time with this most recent request. My preference for the slashes is because a page can be both a container for data (fields) and a container for pages (children). As a matter of consistency, I want to treat all pages the same (at least on my own sites) so that my site's API code doesn't always have to be looking for the presence of slashes when working with selectors, relative paths, url segments and such. I don't want to have to always consider these things when developing a site. As for adding extensions like ".html", that would kill the ability to use page URLs/paths in selectors, unless you actually named your page with the ".html" extension. So if we start adding automatic extensions, I think we start creating a lot more work for the site developers and general confusion... at least I would find it confusing. Sure there might be solutions around the issues, but if something is going to be used on less than 30% of sites then it doesn't belong in the core (which would make extensions a possible good module idea).
  16. I make similar errors every day. It just goes with the territory. Glad you found the solution on that one. Regarding the hidden_path. Assuming that is used to store something automatically at some point, I would suggest not making that part of your posted fields if at all possible. The reason is that someone could manipulate that value and have you overwriting stuff you shouldn't.
  17. Thanks! Let us know how it works out with the videos.
  18. Adam, the page number prefix is site-wide, not template. The slash setting is by template. The default state is for it to enforce slashes, as before. Nothing has changed unless you go into a template and specifically set it to not enforce the slashes.
  19. I will look at adding that option. Though this definitely falls into the court of being something I wouldn't ever use on my own sites, and I would question the value of doing it. If it's for maintaining legacy URLs, you are better off using Apache to 301 redirect them away from the legacy URLs. Also, you can always make pages end with .html by making that the page name, i.e. "mypage.html" rather than "mypage", and turning off trailing slashes.
  20. $categoria = $input->post->categoria; $p->parent = $pages->get("/".$categoria."/"); That code snippet above is not safe because $categoria is not validated/sanitized. Someone could really tear up your site using this current code, since you are using that to find the parent. For instance, what if they manipulated the form so that it was '/processwire/' or some prominent page on your site. Since you are using this to save pages, they could then go in and add a million pages to your navigation. I suggest that you do this instead: $valid = array('categoria1', 'categoria2', 'categoria3'); $categoria = $sanitizer->pageName($input->post->categoria); if(!in_array($categoria, $valid)) die('abort'); $p->parent = $pages->get("/$categoria/"); ...and likewise for the other places where you are doing this. Or better yet, only deal with page IDs in your form, rather than page names. That's better because integers are very easy to validate and may be preferable here: $valid = array(10,11,12); $categoria_id = (int) $input->post->categoria; if(!in_array($categoria_id, $valid)) die('abort'); $p->parent = $pages->get($categoria_id); This is also not safe: require_once('functions.php'); The problem with that is that PHP is searching all the include paths for 'functions.php'. It may very well find the wrong one. Instead, you want to ensure it just operates in the current path, so prefix it with a "./": require_once('./functions.php'); I'm also a little concerned about what hidden_path is, and if there any security implications with that, but I just want to reiterate that you should never trust any user-submitted data. Assume that it is tainted. People will eventually exploit these issues. Don't use anything they submit in selectors, in page data, or echo anything back to the screen unless you've sanitized and validated it first. As for why it's generating the error message... I can't immediately tell what the issue is or why you are getting something from comments (there doesn't appear to be any comments code here). It is possibly the include path issue I mentioned above, though I'm not counting on it. Can you paste in the exact error message that you are receiving? Thanks, Ryan
  21. I made the slash configurable by template. If you download the latest commit, you'll see it as a new advanced setting for each template. Adam, I also made the page number prefix configurable now with $config->pageNumUrlPrefix = 'your_prefix'; If not specified, then it defaults to 'page', as before, i.e. 'page1', 'page2', 'page3', ...
  22. If you are wanting to support two different video sizes, I think your best bet is to just create 2 file fields to handle them (or 1 multi-file field, where you always assume the first is the largest/smallest, or something like that). Lets assume you've created 2 file fields, and named them video_hi_mp4 and video_lo_mp4, and you've added these to your template that handles it. Here's how your template code would look: <video controls> <?php if($url = $page->video_hi_mp4->url) { echo "<source src='$url' type='video/mp4; media='(min-device-width: 800px)'>"; } if($url = $page->video_lo_mp4->url) { echo "<source src='$url' type='video/mp4;'>"; } ?> </video> You'd use the same method for your other video formats.
  23. I think we need to get a look at your whole template file. Chances are that your code to look for a form is just checking if there are posted values, rather than checking for posted values from a specific form. If I'm correct about that, you would want to change your form posting code to save only if it detects the name of the submit button. So here is what I'm guessing it looks like now: if($page->editable() && count($input->post)) { // save the form } What'd you want to do is change it to look like this: if($page->editable() && $input->post->submit_form) { // save the form } Replace "submit_form" the the name assigned to your submit button. If it's just "submit", then you may want to change it to something more specific in this case. If this isn't it, please post your template or email it to me and I can get a better look.
  24. I'm not sure why that error was turning up, and am out of time to take an in-depth look, but I was able to fix it easily. And actually I think it's something I should have had in there in the first place (an extra check to make sure that $controller is not null), so thank you for finding it. I have fixed this in the latest commit: https://github.com/ryancramerdesign/ProcessWire/commit/99454cb68b0ccfe287ab82c68c9db7010a6f94be AdminBar is looking great! Would you mind if I tweeted a link to your screencast?
  25. There is. Try this: $total = $page->children("limit=2")->getTotal(); You have to do "limit=2" (or higher) rather than "limit=1" because PW2 doesn't currently count totals on limit=1 selectors. That's just as a matter of efficiency, since all $pages->get() functions use limit=1 internally.
×
×
  • Create New...