Jump to content

SiNNuT

PW-Moderators
  • Posts

    1,011
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by SiNNuT

  1. The problem i see with your query is that it does and can not make a distinction between templates, and a field can belong to multiple templates. If that's the case your count is gonna be wrong for what Brian wants to do; count pages using templateX grouped by a fields 'unique' values. Seeing that the only foreign key in a field table is 'pages_id' i don't see a simple way of doing a bulletproof query using only the field table.
  2. Not an answer to your question but instead of going through all the templates a workaround could be?: if($user->isGuest()) { echo "login required"; }
  3. I think it definitely is possible with ProcessWire, a lot of the building blocks are already there. I do think that it will take a considerable amount of programming to make it do exactly what you want. Some modules for like/dislike functionality, follow, notifications, streams, front-end logins and such. PW isn't a social platform out of the box. If you are already comfortable with something like Symfony it may be faster using that. Another option would be to checkout specific social networking solutions like buddypress.org or elgg.org
  4. This is already in the default installation, so study those templates and includes. For this particular wish it's something like this (from foot.inc): <?php // If the page is editable, then output a link that takes us straight to the page edit screen: if($page->editable()) { echo "<a class='nav' id='editpage' href='{$config->urls->admin}page/edit/?id={$page->id}'>Edit</a>"; } ?>
  5. The module Markup Simple Navigation has first/last class functionality so you could look at that code or just use the module for your project, it's quite nice. Or style it with CSS :last-child (beware, no IE 6-8 support, but it can be done using http://selectivizr.com/)
  6. PW is a flexible tool. So if you wanted a way to set some site-wide settings and manage them from the admin you could: Create a template called something like "settings". This can be a file-less template. Create fields for the settings you wish to have, for example 'sitename' and 'companyslogan'. Add the fields to the settings template. Create a page with the template 'settings'. The page can be named anything but let's also call this 'settings'. Make the page hidden and publish. Now you can use this data in your templates using the PW api. $settings = $pages->get("/settings/"); <title><?= $settings->sitename; ?> | <?= $page->get("headline|title"); ?></title> <h2><?= $settings->companyslogan; ?></h2> This is only one way. Another way would be to do this settings in the config file.
  7. Glancing through the code associated with the datetime field i guess when you don't explicitely set an output format it falls back to: const defaultDateOutputFormat = 'Y-m-d'; // FieldtypeDatetime.module On the db level FieldtypeDatetime is a MySQL datetime type. getUnformatted seems to give you the wakeupvalue. /** * Convert value from timestamp to Y-m-d H:i:s date string * */ public function ___sleepValue(Page $page, Field $field, $value) { return date('Y-m-d H:i:s', $this->_sanitizeValue($value)); } /** * Convert value from Y-m-d H:i:s string to timestamp * */ public function ___wakeupValue(Page $page, Field $field, $value) { return strtotime($value); }
  8. It would, but totoff wants to format $page->closing differently depending on the template he uses it on, or at least that how i interpret his question. If this is not the case, then of course you could just set the desired output format in the field settings and just do 'echo $page->closing'
  9. PHP's date expects a Unix timestamp. $page->closing most likely returns a formatted date that is set in the fields output formate setting. Try: <?php echo date("Y-m-d", $page->getUnformatted("closing")); ?> The created and updated system values return unix timestamps by default i think, so this is why they work in your example.
  10. SiNNuT

    New pw site

    I see. Maybe this is personal but when i scroll down i just think "hmmm..ok..nothing here", and am left wondering why i see some 'nothingness'. I'm not triggered in any way to consider the bg image on the html as actual content with a purpose. Even if i was triggered i wouldn't have any way of figuring out what it's supposed to convey. Is it her place of business or some random stock image? I don't know. Don't mean to knock your work here, because like i said, i like it.
  11. SiNNuT

    New pw site

    Clean and simple, i like it. Is there any particular reason for the padding-bottom of 548px on the body that i'm missing? A lot of scrolling without revealing any content?
  12. I agree with you that the prize is a joke but remember that Yugoslavia was not part of the EU. So the no war statement does hold up if look formally at EU members.
  13. Come to think of it, i'm not sure how js handles paths. In CSS paths are handled relative to the css file itself. Simple. In js url's are relative to the resource that calls it? Dunno, maybe you should use a root relative or even absolute path/url. How do most js users do this?
  14. The site root (homepage) is shown fine? It could be some .htaccess problems. Is PW installed in subdirs? Can you echo $config->urls->admin is the home template? Plz give as much info as possible
  15. The js is loaded correctly but it fails to find the image? I think somehow you declare the path wrong. Can you show the image call in your js file?
  16. Sounds interesting. A minor suggestion; the h1 seems to get mangled in FF (16.0.1) somehow. Chrome and even IE (9) seem ok.
  17. Haven't used language support myself but this is what Soma said: So indeed try setting setlocale in config.php without languagesupport installed. Or ofcourse, when you know the working locale value you should also able to set this in this in set in the translation of the language for the LanguageSupport.module. Let me know if it works.
  18. Hi Michael. I don't think it's the right way to install language support only for the sake of displaying localized dates. The problem with setlocale can be that the list of installed locales can change from server to server, also in relation to the OS the server runs. So there is no guarantee that setlocale(LC_ALL, 'de_DE'); works on all systems. If you're on a *nix system you can probably look up the available locales by doing, <?php system('locale -a') ?> or run this the command, locale -a, from the terminal. If that doesn't work you can try an array in config.php in which you just put the most common variations, then it will try them all. Something like, <?php setlocale(LC_ALL, array('de_DE.UTF-8','de_DE@euro','de_DE','german')); ?>
  19. I guess you would adjust a function like that to generate your menu so that is outputs links like <a href="/businesses/A/">A</a> <a href="/businesses/B/">B</a> Then you could use url segments and something like $page->children("title^=$input->urlSegment1"); Anyways, just thinking out loud here. Curious as to see what more seasoned pro's think. That function Mats linked to is efficient, even when you've got a lot of children? In MySQL you would do something like: SELECT DISTINCT LEFT(title, 1) as letter FROM mydatabase ORDER BY letter
  20. slightly ot but whenever i get a chance i like to hotlink this xkcd classic
  21. Definitely +1 for PSR-0 because that seems to me like having a lot of benefits and has gained a lot of traction with stuff like Composer|Packagist. It just seems like a great idea that you can easily and reliably add third party packages to a PW project. (and possibly vice versa?) Projects aren't isolated islands. A lot of projects have the potential to be a mix and match of tools. Maybe PW, a templating system and your favorite validation package. Wouldn't it be neat if there was some sort of consistency between php projects? Don't argue about tabs vs spaces, snake_case or stuff like that but just settle on a standard and be done with it. Of course for a standard to be effective it should make at least some sense (you don't necessarily have to agree with everything) and have widespread adoption. I wouldn't consider PSR-1&2 to be something very important but it wouldn't be bad if PW was compliant with it.
  22. You could look at the PHP Framework Interop Group and their PSR-1 and PSR-2 coding standard and style guide. There are a lot of of big names amongst their members so it does have some weight to it. Fun fact: they settled on using 4 spaces for indenting, which was cause for some debate. http://paul-m-jones.com/archives/2312 It would be good for PW to encourage the use of some coding style. This will benefit stuff like modules greatly in the long run. - darned, beat to it -
  23. I'm still relatively new to PHP, so there are quite a few goodies in there for me to study. For example the datetime stuff : http://www.phptherightway.com/#date_and_time http://philsturgeon.co.uk/blog/2012/08/why-php-datetime-rocks Seems like some good stuff.
  24. A pretty neat quick reference to (modern) PHP. With info for beginners but it can also be of use for those already 'in the know'. http://www.phptherightway.com/
  25. I know teppo, but not until long ago the master branch was actually ahead of the dev branch in terms of code and features most of the times. So i was just wondering if we can now assume that master is 'stable' / production ready branch and that all new stuff goes via dev first.
×
×
  • Create New...