Jump to content

Pete

Administrators
  • Posts

    3,901
  • Joined

  • Last visited

  • Days Won

    59

Community Answers

  1. Pete's post in If Checkbox is checked, post Data else... was marked as the answer   
    I believe this is all you need:
    if ($page->footerChecked) {     // true } else {     //false }
  2. Pete's post in Custom admin form AJAX files issue was marked as the answer   
    I ended up ripping apart my code and starting again
    The original version was based on an older version of Fredi, so I went back and found that Apeisa was doing something totally different there now. Sure enough, adapting the newer Fredi code for my purposes worked well.
    It also gave me some good ideas for quick custom admin forms too but I don't think there are enough hours in the day to work on all these ideas unfortunately
  3. Pete's post in double module wire and site was marked as the answer   
    CKEditor is already in the core of ProcessWire nowadays so you don't need to install it again. Simply delete the /site/modules/InputfieldCKEditor/ folder and it will go away.
    Several versions ago, TinyMCE was the default, so that's why the module exists, but isn't needed on newer installations.
  4. Pete's post in Is it wise to use ProcessWire for a multi-user Intranet knowledge base? was marked as the answer   
    I think this is your limiting factor here. I have built something similar as part of a wider, integrated intranet system however if your time is short you can't beat using some pre-existing software.
    Nothing will beat ProcessWire if you are likely to want to introduce functionality not available in some other system as ProcessWire is one of the few platforms where you can change your mind about something or come up with crazy new ideas and it not be a problem to make larger changes, but if you're likely to only need a normal WIKI type system then you probably won't replicate all the functionality you want in just a few weeks.
    That said, I hate that MediaWiki seems to be the main option out there (there are others, but they all come with their own maintenance issues too) as it's a bloated piece of software (so slow and resource hungry for what it does) on an out of date codebase in my opinion. I would love to have the time and money to develop something in PW as coupled with ProCache you'd be onto a winner and have something infinitely more customisable if a lot simpler, but it would be a project that would take several months at least I would think to cover everything (well, the basics) of what something like MediaWiki can do.
    Not sure where my train of thought is going, but I guess if you're really tight on time, you should probably invest that in installing, skinning and getting to grips with something that already exists. If the project is longer-term overall (as in you'll be looking after this system for years), then this buys you time to develop something as a version 2 and does you a favour in a way as you'll know what the client does and doesn't use in the system you've installed so you know where to focus your efforts in a custom-built system.
    Hope that's of some help anyway.
  5. Pete's post in If page is last, show link to first setup was marked as the answer   
    Try $page == $page->parent->children->last().
    EDIT: Gah, there's a way to do it with siblings() where it includes the current page in the siblings() PageArray but the correct code eludes me and I suspect diogo will beat me to it

    Oooh, you could do
    if ($page->next) { // show the next link - $page->next; } else { // show the link to the first again - $page->siblings->first(); } I think.
  6. Pete's post in Select field for persons height was marked as the answer   
    Enter all the heights as pages and make a Page field that renders as a Select field would be my suggestion.
    I think you've used Page fields before so I'm a little confused by the question as you're almost answering it as you're asking it if you see what I mean?
  7. Pete's post in hidden vs unpublished - for select values was marked as the answer   
    IF there is a template file for those pages.
    Often for select fields I create a Tools template which is just an empty template with no file. That way I can set up things like selects (where I don't want them to be pages on the site) and not worry about anyone guessing the URL.
    I always set them to hidden. Unpublished implies you're not wanting to use a page yet.
  8. Pete's post in migration from wordpress to processwire was marked as the answer   
    Hi Pravin
    There's a manual way: https://processwire.com/talk/topic/3987-cmscritic-development-case-study/
    Or a new converter - install this: https://github.com/adrianbj/ProcessMigrator then this: https://github.com/NicoKnoll/MigratorWordpress and follow the instructions on the second link there
    The topic discussing the migrator is roughly here: https://processwire.com/talk/topic/4420-page-list-migrator/page-6
  9. Pete's post in all items from member on member page was marked as the answer   
    Seems about right.
    Nothing wrong with the way you've done it, but the short one-line version would be:
    $userpages = $pages->find("template=child-template, created_users_id=" . $users->get($page->name)); Rather than using $selects all the time, I would name it something more meaningful like $userpages above, then iterate through them: foreach ($userpages as $userpage) { ...
    It's more descriptive when you build your template file up and there's lots going on - helps you keep track of things a bit easier especially when you're using multiple PageArrays on a page, though it's not essential to do this and everyone has their own preference and naming style.
  10. Pete's post in roles and access? hide from guest/member... was marked as the answer   
    Yet another way to check for guests only is with $user->isLoggedIn()
  11. Pete's post in rangeslider field selector in link possible? was marked as the answer   
    If they're hours as in 24 hours in a day, could you not just do something like this:
    for ($i=0; $i <=23; $i++) { // Regular PHP - see http://www.php.net/manual/en/control-structures.for.php     echo '<a href="' . $page->url . $i . '/">' . $i . '</a>'; // which will output as <a href='/your-page/4/'>4</a> - well, it will output 0 - 23 in this way so you'll have 24 hourly links for example } Not quite sure what you mean by "link" in this case, but you could use something like the above with a selector that uses the urlsegment and searches for pages with 4 in the rangeslider field - see this example adapted from the rangeslider instructions for the selector if you wanted to match any page with a range that encompassed "4":
    $pages->find("range.min<=4, range.max>=4"); // So if minimum is less than or equal to 4 and maximum is greater than or equal to 4, get those pages. You'll probably want to specify a template as well but you get the idea
  12. Pete's post in Can't get it to work - $input->urlSegment1 was marked as the answer   
    Exactly what Soma said.
    What you are trying to do above when you say $page->title works sounds like you're trying to find all pages with the template "child-template" that have the current page in the "provincie" field, so you don't need to do anything more complicated than this (because $page is the current page):
    $selects = $pages->find("template=child-template, provincie=$page->id"); Or if you don't specify a field on the end of $page then it returns the page ID anyway:
    $selects = $pages->find("template=child-template, provincie=$page"); It sounds like you're trying to find other pages that relate to the page currently being viewed, so you should always try matching the current page's ID, assuming "provincie" is a Page fieldtype? For that fieldtype pages are stored using their IDs.
    UrlSegments is just over-complicating things at this stage
  13. Pete's post in select - how to? was marked as the answer   
    If you want to echo the title, just do $page->select_branche->title
    Without specifying a field on that page you only get the page ID. You can also get the name and any other fields in a similar way.
  14. Pete's post in Adding role to many users was marked as the answer   
    You can write that as something like this (pipe symbol | means OR):
    $usersWithoutRole = $users->find("roles!=gooduser|guest|superuser"); You don't need to try and partial match if you know the exact names of the roles.
    If you just want to make sure every user has the guest role though, just re-add it regardless of whether they have it or not like this:
    foreach ($users as $u) {     $u->addRole('guest');     $u->save(); }
  15. Pete's post in Custom Content Type? was marked as the answer   
    Hi Helmut
    In ProcessWire everything is custom. I would suggest watching the overview video for starters: http://processwire.com/videos/ and perhaps playing with this tutorial to get an idea of what you can do with some of the different fields: http://processwire.com/talk/topic/693-small-project-walkthrough-planets/
     
  16. Pete's post in Find filenames of uploaded files? was marked as the answer   
    Welcome to ProcessWire!
    Assuming your file field is called "files" in the admin, you could do this in your template:
    <?php foreach ($page->files as $file) { echo "<a href='$file->url'>$file->name</a> }You could also substitute the name with the contents of the description field too.A pretty complete list of functionality can be found on the cheatsheet at http://cheatsheet.processwire.com
  17. Pete's post in Where do I find the FIND function in the skyscrapers demo? was marked as the answer   
    I think you should probably take a look at the concept behind ProcessWire first, then some of the other docs and the cheatsheet as Macrura suggest - start with the Concept page from here: http://processwire.com/api/
    The Cheatsheet then gives you a look at most the possible functionality at your disposal in page templates to access your data and files.
    As for explaining the line of code you quoted:
    $skyscrapers = $page->skyscrapers->find("limit=3, sort=random"); From memory, "skyscrapers" is actually a "featured skyscrapers" field, so is just a Page field that links to other pages (probably the most useful fieldtype there is. Here is the exact translation:
    "For the current page (homepage in this instance), find 3 random pages from the skyscrapers field". The $skyscrapers = bit is just storing the results in a PageArray (it's in the docs linked further up my post here) that can then easily be iterated through to print whatever output you desire. If you're wondering why the demo doesn't seem to pick three random pages, I think page caching must have been accidentally left on here so it's always showing the same 3 in the demo, but that's easy to switch off
    The syntax is based on jQuery and aims to be human-readable. If you imagine that there are a few database tables and queries behind that code, you can easily see how quick that is to write and all without a line of SQL.
    You can make all sorts of queries like:
    $architectsCalledPaul = $pages->find("template=architect, title*=Paul"); // finds all architects (pages with the template "architect" with the name Paul somewhere in the title field   // and so on... The idea behind ProcessWire is that once you've learned the basics you can build pretty complicated data structures in the admin quicker than you'd be able to writing database tables from scratch and you have a hugely powerful set of functions at your fingertips to do with that data as you please.
    Most folks here would agree that it has shaved hours/days/weeks/months off their site build times depending on website scale, but any time saved is good!
  18. Pete's post in Finding and posting repeater fields from another template was marked as the answer   
    Stop me if I'm wrong, but does the stockist template only apply to one page? If that is the case, you need to create a stockist.php template file which will load when you browse to that page with something like the following code:
    <?php foreach ($page->store_middle as $store) {     echo "<h5>$store->store_name</h5>";         echo "<p class='less_padd'>$store->store_address</p>"; } However, if you have more than one page using the stockist template then something like this would work:
    <?php foreach ($pages->find("template=stockist") as $stockist) {     foreach ($stockist->store_middle as $store) {         echo "<h5>$store->store_name</h5>";             echo "<p class='less_padd'>$store->store_address</p>";     } } What I have noticed is that you mentioned _left and _middle in your code, so that might be causing an issue too. You also hadn't closed your opening <p> tag which might be hiding some content perhaps?
    Hope that helps.
  19. Pete's post in Hide page instead of trash or delete was marked as the answer   
    Thanks again Soma, I feel like an idiot right now having the status as a string (not done it anywhere else in my modules so was just being blind ).
    All working now - for those interested, this is the final code:
    public function init() {     $this->pages->addHookBefore('trash', $this, 'preservePages');     $this->pages->addHookBefore('delete', $this, 'preservePages'); } public function preservePages(HookEvent $event) {     $page = $event->arguments[0]; if ($page->template == 'template-name') {     $page->addStatus(Page::statusHidden);     $page->save(); $event->replace = true;     $this->message("The page was hidden instead of deleted. Pages using the '" . $page->template . "' template can be linked to other pages, so deleting is prohibited"); } } As you can see, much simpler after Soma's expert help.
    @Soma: I can't mark both your replies as the Solved post, so will have to mark this one with the full code if that's okay?
  20. Pete's post in Include pw header and footer in other script was marked as the answer   
    I'm confused - this would surely just echo the URL of that page:
    echo $header_page->url; ??
    To render it you would want this instead: $header_page->render();
    So in your other script, you could do this:
    // Include ProcessWire require("../index.php"); // Get header $header_page = wire()->pages->get("/external_head/"); $footer_page = wire()->pages->get("/external_foot/"); echo $header_page->render();   //.... the rest of your other script goes here   echo $footer_page->render(); That should work I think, unless I've misunderstood what you're asking for. It also assumes that there will be no conflicts between variables in ProcessWire and your other script, but you would know if that's the case soon enough when it throws you errors
    I must admit, I do like the concept. I know of an intranet script I've worked on in the past where I tried to make ProcessWire work inside that script's header and footer for old pages, and new pages had the header and footer and the pages themselves in ProcessWire, but this would have been a better idea in terms of wrapping a consistent header and footer around both the old and the new pages until they're all ported over to ProcessWire.
  21. Pete's post in Child Thumbnails was marked as the answer   
    Exactly what diogo said. So if your thumbnail image field is called "thumbnail" then replace the img src with $child->thumbnail->url (or if it hasn't been specifically set to only allow one image to be uploaded to that field it might be $child->thumbnail->first()->url if the field is set to allow multiple images).
  22. Pete's post in Solved-Button was marked as the answer   
    You mean like this?
    I just enabled it in this forum for a test, as well as Getting Started, General Support and Modules & Plugins.
    I can see it needs some styling though so it stands out a bit more.
  23. Pete's post in Install problem: fail ICONV Support was marked as the answer   
    It sounds like iconv isn't installed on the server - just need to ask Liquidweb to install it for you - that's all.
    I'm guessing the person who runs the hosting has a VPS package as usually they don't have many modules installed by default.
    if you want information as to what iconv actually does I'd suggest Googling it, but all the error during install is telling you is that a required module isn't installed and you need it to use ProcessWire properly.
    In fact, here you go - looks like something to do with supporting different languages/characters: http://www.php.net/manual/en/intro.iconv.php
×
×
  • Create New...