Jump to content

ryan

Administrators
  • Posts

    16,772
  • Joined

  • Last visited

  • Days Won

    1,531

Everything posted by ryan

  1. I have a question from a client that I didn't know the answer to, and was wondering if anyone here does. Lets say you have an RSS feed in ProcessWire outputting your news stories. Is there a way to setup Twitter and/or Facebook (even if 3rd party tool required) to automatically send out a new tweet/post when something is added to the RSS feed? I would think there should be, but just didn't know. I do know you could do it with their APIs, but didn't know if one could connect an RSS feed to their Twitter/Facebook feed.
  2. I like that idea, being able to swap in a larger chunk of markup like that. I need to give this a try. I really like this thread, you guys have some great ideas.
  3. Yes Dictator was a bad name. But it had good intentions. It was the name of one of Thomas Edison's inventions for some machine that assisted with outputting content. It was supposed to be that kind of Dictator, not the kind that tells others what to do or an evil ruler or anything like that.
  4. Thanks for posting Soma, this is an interesting approach and not one I've seen before, but it looks great. The underlying concept and result is similar to the approach I usually use. Since you posted a good description, I'll try to do the same for mine. The only reason you see head/foot files in the default PW profile is because it seems to be simpler for new users to grasp. But I almost never use that approach in my own sites. Like your system, I have a main.php file which is my main markup file. But unlike your system, main.php is included from all the other template files (rather than main.php including them). The other template files focus on populating the key content areas of the site, specific to the needs of the template. Examples of key content areas might include "main" (for center column/bodycopy) and "side" (for sidebar/related info), though often includes several other identified areas. But I'll keep it simple in this case. Here's how it works: basic-page.php <?php $outMain = "<h2>{$page->subtitle}</h2>" . $page->body; if($page->numChildren) $outMain .= $page->children->render(); // list the children $outSide = $page->sidebar; include("./main.php"); main.php <html> <head> <title><?php echo $page->title; ?></title> </head> <body> <h1><?php echo $page->title; ?></h1> <div id='main'><?php echo $outMain; ?></div> <div id='side'><?php echo $outSide; ?></div> </body> </html> The benefit of this approach is that basic-page.php can setup whatever it wants in the key content areas ($main or $side) whether simple like in this example, or something much more complex. I actually prefer for the variables representing the key content areas to be optional. In the scenario above, $outMain and $outSide would have to be defined by every template or they would end up as uninitialized variables in main.php. As a result, I actually use $page as an anonymous placeholder for these variables (making sure they don't conflict with any existing field names) and then let main.php assign defaults if the calling template didn't specify one of them. For example: basic-page.php <?php $page->outMain = "<h2>{$page->subtitle}</h2>" . $page->body; if($page->numChildren) $page->outMain .= $page->children->render(); // list the children // note: no $outSide specified include("./main.php"); main.php <?php // setup defaults when none specified if(empty($page->outMain)) $page->outMain = $page->body; if(empty($page->outSide)) $page->outSide = $page->sidebar; ?> <html> <head> <title><?php echo $page->title; ?></title> </head> <body> <h1><?php echo $page->title; ?></h1> <div id='main'><?php echo $page->outMain; ?></div> <div id='side'><?php echo $page->outSide; ?></div> </body> </html> Final thing to point out here is that main.php is the only template actually outputting anything. Because basic-page.php (or any other template) is determining what's going to go in that output before it is actually sent, your template has the opportunity to modify stuff that you might not be able to with other methods. For instance, the <title> tag, what scripts and stylesheets are loaded, etc. Here's the example above carried further to demonstrate it: basic-page.php <?php // make a custom <title> tag $page->browserTitle = $page->rootParent->title . ": " . $page->title; $page->outMain = "<h2>{$page->subtitle}</h2>" . $page->body; if(count($page->images)) { // display a clickable lightbox gallery if this page has images on it $config->scripts->add($config->urls->templates . "scripts/lightbox.js"); $config->styles->add($config->urls->templates . "styles/gallery.css"); $page->outMain .= "<ul id='gallery'>"; foreach($page->images as $i) { $t = $i->size(100,100); $page->outMain .= "<li><a href='{$i->url}'><img src='{$t->url}' alt='{$t->description}' /></a></li>"; } $page->outMain .= "</ul>"; // add a note to $page->title to say how many photos are in the gallery $page->title .= " (with " . count($page->images) . " photos!)"; } if($page->numChildren) $page->outMain .= $page->children->render(); // list the children include("./main.php"); main.php <?php // if current template has it's own custom CSS file, then include it $file = "styles/{$page->template}.css"; if(is_file($config->paths->templates . $file)) $config->styles->add($config->urls->templates . $file); // if current template has it's own custom JS file, then include it $file = "scripts/{$page->template}.js"; if(is_file($config->paths->templates . $file)) $config->scripts->add($config->urls->templates . $file); ?> <html> <head> <title><?php echo $page->get('browserTitle|title'); // use browserTitle if there, otherwise title ?></title> <?php foreach($config->styles as $url) echo "<link rel='stylesheet' type='text/css' href='$url' />"; foreach($config->scripts as $url) echo "<script type='text/javascript' src='$url'></script>"; ?> </head> <body> <h1><?php echo $page->title; ?></h1> <div id='main'><?php echo $page->get('outMain|body'); // use outMain if there, or body otherwise ?></div> <div id='side'><?php echo $page->get('outSide|sidebar'); // use outSide if there, or sidebar otherwise ?></div> </body> </html> More than half the time, I'll actually just re-use page variables like $page->body and $page->sidebar rather than $page->outMain and $page->outSide. That way there's no need to consider defaults, since $page->body and $page->sidebar untouched technically are defaults. <?php $page->body = "<h2>{$page->subtitle}</h2>" . $page->body . $page->children->render(); But technically you've got a little more flexibility using your own self-assign anonymous variables like outMain and outSide, so figured I'd use that in the examples above. outMain and outSide are just example names I came up with for this example and you could of course name them whatever you want.
  5. You'd have to use a little bit different approach because a session has to be active before we know who the user is. The session hasn't yet started when the config file is being loaded. So you'd detect who the user is somewhere else (like in your main site template) and then set a cookie before any output starts: setcookie('guest', $user->isGuest() ? 1 : 0); Then detect the cookie in your config.php: $config->sessionExpireSeconds = empty($_COOKIE['guest']) ? 86400 : 23200; You wouldn't want to use this method for anything security related, but session time is really not a security concern I don't think.
  6. Good catch, I've updated the original code example too.
  7. Great feedback, thanks Maruchan! It's interesting to see that ready-to-go site profiles and training materials are your top two. Both of these appeal to me a lot, definitely something to think about more. I might have to test the waters with a ready-to-go site profile to gauge interest. Beyond those that you mentioned, are there any other ready-to-go site profiles that you think there would be good demand for? With regard to books, I'd love to have two "abookapart" sized/styled ProcessWire books: one for developers, and one as a user guide that we can provide to our clients after building a site for them. Though even if not full-blown references manuals, such books would take serious time and resources to create. But I've got two things working for me on that front: my brother designs books and my dad owns a book publishing company. I'm going to have a little chat with them this weekend. However, with family in the book publishing industry, I'm well aware that one does it for the love and not the money... most books lose money. Still, I think ProcessWire book(s) might do well, so I'm going to find out how much it'll cost for the production.
  8. Currently that's not possible, but I think it would be easy for us to add an nl2br() function to convert newlines to <br /> tags in the field description output. Let me know if that's what you are looking for and I can add it.
  9. Thanks for the updated French translation! I pushed an update this morning that changes one aspect with regard to the 'default' language selection. Now you no longer select a default language from the LanguageSupport module config screen. Instead, the default language is the one installed by the module. Previously it was called "English". Now it's just called "Default" and you rename it to whatever you want. If your default language is French, then you rename it to French and upload your French files there. The reason for this is two-fold: 1) Lots of sites don't need English; and 2) The default language is not deleteable. So I figured it's better for those that just need French (for instance) to only have French and not bother with having some non-deleteable English language installed in the system. Besides, since PW is in English when untranslated, any language that you create is already using English until you put in translation files to change it. So there's no reason to have a permanent English placeholder language. Also, I've added a new module to the system and it's ready for translation. To translate it, click 'new' at the bottom of your translation files and paste this in: /wire/modules/Process/ProcessPageClone.module Don't worry about updating your translations just yet because there are still more modules being translated. So you may just want to wait and do them all at once. But I just wanted to mention that one above because it's a new one rather than one that's already in the system.
  10. Nobody's said anything about making PW commercial. It is a "truly" open source project in every way possible and that's not going to change. I don't want any implication of anything other than that. I don't personally have any commercial aspirations with ProcessWire. My interests are in helping it to grow as an open source project and meeting the needs of the community. I'm not here to make a buck. People don't get into open source for the money (there's no money in it). Instead, I'm here to put money and time in it – I saved for a few years to pay for the time it took to make ProcessWire as an open source project. I did it for the same reason that one would invest a lot of time and money building model airplanes or trains… it's what I enjoy doing. Especially now that there's so many of us. I find the work and community here hugely rewarding, surpassing anything I could have ever been paid. There's no expectation of making money here. But now that we've got a dedicated community, I do think we've got a responsibility to chart a path forward for growth so that the product can grow with the community and continue to meet their needs. My financial resources are not unlimited and I've got a family to feed. I can do that by taking on more client work, and just work on PW on my spare time. But my preference would be to find a way to make ProcessWire self-sustaining, so that it can grow on it's own funds more than mine. I'd also like for myself and others to be able to afford to put more and more time towards it. Actually, I'm determined to put more time towards it even if it means going without sleep. While I'm not sure if it's the right path or not, I do like aspects of the idea of having options for commercial modules. I think it could help us to attract high-profile and mission critical websites, and service-oriented module developers that can bring more exposure to ProcessWire… increase its audience and help it grow. I also think that providing a centralized gateway for modules (free and commercial) serves our community a lot better than the alternative. Whether anyone will actually build any commercial modules remains to be seen, but I'd like to encourage high quality 3rd party module development, free and commercial. I have no problem if someone wants to make a buck on creating a commercial module, so long as they make it good and support it well. If we don't serve as a gateway for this stuff, then we have no means of effecting the quality and service to our community. Perhaps C5 is making some mistakes in the manner in which they are doing this, and it would be good for us to study what they are doing right and wrong. If its really hurt their community there, and that's a widely held opinion, then that would be a good reason not to use them as a potential model. I like Symphony's model of making commercial support options available. I think this is another thing that attracts high-profile and mission critical websites, while also supporting development of the CMS. Though I have no idea if it's been successful for them or not. Correct me if I'm wrong, but the WordPress business model is primarily centered around hosting. I'm not sure this model translates to ProcessWire very well, because our audience is more web-professionals than bloggers and writers. It would be interesting to know more about why WordPress supports commercial themes but not commercial plugins. I am wondering if their plugin system is such that anything built on it has to be GPL. Whereas ProcessWire's templates and modules are using the same interfaces and API. What are other ways that WordPress or other open source CMS projects are growing in a self sustainable way? Some other ideas are books, commercial tutorials and training (videos or in-person), commercial site-profiles (ready-to-go school website, or the like), custom module development (for individuals), selling advertising (though not very interested in this), coffee mugs and t-shirts. Please throw some more ideas into this if you have them. Ultimately if the community isn't supportive of any specific business-models, then we'll throw the ideas out because the project will grow and move forward either way. But I'd like to get to the point of being able to put more and more time towards the project, so just looking for ways to do more PW work and less client work.
  11. I'm not sure that I understand your setup well enough to be able to provide a good answer on how you should change it. So I'll just mention some general guidelines. For sites where you need to maintain multiple points of access, t's best to narrow in on your primary points of access change in your site, and use a unique template to serve as the access parent. Then let everything below it inherit that access, and control what can go where with family settings in the templates. To get template selection of new pages per role, you would give the role edit access to that template (or let it inherit it from another). Then in family, select the allowed parent templates. You've now defined what roles can create new pages using that template. To keep it simple, inheritance is all or nothing in 2.1. You don't inherit some things from one parent and others from another, like in PW 2.0. You inherit everything from the access parent's template, which helps to reduce confusion (relative to 2.0). 40 templates is a lot even for a large site (more than I've ever used) so I do wonder if that is necessary, though I'm sure there are cases where it may be, but it's something to look at.
  12. Antti I think you are right, that must be what he's talking about (fieldgroups). From the admin side of things, Fieldgroups and Templates function as one component. While you can maintain separate Fieldgroups from the API side, you don't have a way to manage them separately from templates in the admin.
  13. Stop using Firefox 3, we're on version 8 now. But if you find there is still an issue in newer browsers, you might also want to check your post_max_size in PHP settings. That has to be a number at least as large as your max_upload_size.
  14. Also check that the template you are using with this (contact) doesn't have caching turned on. If you need to use caching with the form, you'll want to specify a POST or GET var that must be present to disable the cache (see the cache settings in the template).
  15. I'm not sure why they wouldn't be showing up in your fields list, unless they somehow got system flags. Try clicking in the filter options and 'show built-in fields', to see if they show up there? Another question: what is the name of the fields that you created via the API?
  16. You can also detect if a hook is coming from an admin save by checking the value of wire('process') in your $pages->save() hook: <?php $process = wire('process'); if($process && $process->className() == 'ProcessPageEdit') { // this is an admin save }
  17. Take a look in /site/config.php. A few lines down you'll see this line: <?php /** * sessionExpireSeconds: how many seconds of inactivity before session expires * */ $config->sessionExpireSeconds = 86400; Change that to adjust how long you want sessions to last.
  18. I'm not quite sure I'd want to delegate all my file management over to Git. That seems like a major sacrifice relative to having SSH, but maybe I'm just not used to the idea yet. I'll have to try it at some point before I judge it. But you are right that the provided resources just don't seem to be a good enough of a deal to motivate one to try something new. I need to check out the Storm on Demand that you mentioned, that sounds interesting. Their 2GB plan looks nice and sounds like a better deal than the VPS I've got now. Though I can't determine if it's fully managed (they list 3 tiers of management, but don't say what applies) and I can't tell of it comes with cPanel?
  19. Slkwrm, thanks for your kind words, glad you are enjoying ProcessWire. With regard to flexibility, I would just say that I prefer to let the project dictate the best way for things to go together rather than the platform. I think that comes from being a bit old school about design/development and not wanting CMSs interrupting the design/development workflow. I've written a few CMSs already over the last 10 years, several custom platforms and a couple previous products (Dictator and ProcessWire 1), so I guess I've had plenty of time to make mistakes, learn from them, and hopefully ProcessWire benefits from that. But don't give me too much credit, because it's mostly just trial and error, and time. Give credit to yourself and the community here– ProcessWire is far better as a result of the community. Everyone here is helping to make it a much better and more flexible product than I ever could have on my own.
  20. This looks very interesting, and I like the sound of anything that would let us be able to scale to handling high traffic out of the blue. But I'm completely lost once I get to either site–I'm going there looking for hosting, but they are just talking about developing applications and using Git. Even after reading and watching the videos, I'm not clear about what exactly these services are – I must be having a dumb moment today. I found something I could relate to on the pricing page but it's all pointing to really expensive shared hosting. Has anyone used these are knows what they are? Do you get SSH and root access? I see lots of talk about scalability, but relatively limited resources called out on the pricing page. What advantages and disadvantages does this have over having your own dedicated server or VPS?
  21. That's good to hear, I wasn't aware of that. I just remember using C5 and seeing scalability concerns and client support nightmares all over the place. But that was awhile ago. Based on how they are growing, I think their business model is one we can learn from, especially with regard to the marketplace they have there.
  22. That's correct. The 'modified' field is meant as a system field and nothing else in the API has access to change it (or prevent changes to it). I'm thinking I can provide an override for cases where we are just saving a field ($pages->saveField($page, 'field') or $page->save('field')) as opposed to the whole page. I can set it so that if $page->modified < 0, then it'll ignore it when doing the save, leaving the existing modified time in place. Then a module like the Comments module could feasibly tell the $page not to update it's modified date.
  23. Thanks for this info and link–that's a great reference. It looks like the language codes generally line up with the codes we're recommending people use for their language names (at least for the first 2 characters), but I don't think we can count on that. I think what we'll do is have this module's installer add a field to the 'language' template (when present) that lets one specify the Google Maps language code for each language. Then this module can just get the language code from $user->language->gmap_lang; or something like that.
  24. This has been added in the latest commit of the 'dev' branch (for 2.2). You'll see the Field duplicate/clone option under the 'advanced' menu when editing a field. From there, you just check the box asking you if you want to clone the field and click save. You can also access it from the API like this: <?php $field = $fields->get('title'); $clone = $fields->clone($field); The new field that is returned ($clone) has already been saved, so you don't need to save it again. Also note that it automatically assigns a new name to the field to ensure it's unique. Like with cloned pages, it adds an incrementing number to the end of the name: <?php $clone = $fields->clone($field); echo $field->name; // would print 'title'; echo $clone->name; // would print 'title_1'; You can of course go back and rename it to whatever you want. <?php $clone->name = 'something_else'; $clone->save(); Template duplicate/clone An identical clone() function was also added to the template editor. You'll see it in the 'advanced' menu when editing any Template. When you clone a template, the Fieldgroup is cloned and the template-file is also cloned if /site/templates/ is writable. Using it in the API is exactly the same as with cloning a field, and the behavior is exactly the same: <?php $template = $templates->get('basic-page'); $clone = $templates->clone($template);
  25. Nice job with the new site! Glad you found ProcessWire to be flexible with the development. Did you develop the blog section in ProcessWire too? What did you use for the contact forms?
×
×
  • Create New...