Leaderboard
Popular Content
Showing content with the highest reputation on 02/04/2016 in all areas
-
Here's the latest version of the MVC-ish structure I was referring to in my previous post, in case someone wants to take a peek: https://github.com/teppokoivula/pw-mvc/.6 points
-
Update: Theme Switcher + remake of dark theme OK, because you all asked nicely, and because I don't want @teppo's eyes aching (although he might have been looking at my theme through his cool sunglasses ) and because I don't want @horst to feel 'Ough', I have hurried this up . OK, jokes aside... Theme switcher now included (quite a trivial thing really). The default is the light theme that ships with APIGEN (actually, it also has a Bootstrap theme that it ships with). If you prefer the dark theme (I've gone easy on some colours), just click on the dark box. It will set a cookie and remember you...for a whole year!! If on the light theme, no cookies for you, sorry . When I get time I will write those EU cookie thingys. Something like 'if you are visiting me and would like to stay in a room surrounded by cool, then you must accept to eat my cookies! What do you mean you don't like my cookies? What's wrong with my cookies!? If you don't like my cookies then you stay in the light room'....OK, a bit OTT there (I had a WillyC moment, but failed miserably...am trying too hard, I know )... Btw, there's the occasional flash of 'light theme' when surfing using the dark theme. Am not too bothered about it so will let it be for now.. Anyway, update's here! Later..6 points
-
...ok just do it as with a regular Page $u = new User(); $u->template = "custom-user-template"; $u->parent = "custom-user-parent"; $u->save(); Sometimes you need to spoil your forum karma to get your head working as it should)4 points
-
I guess that's one of the rules cut in stone, as it's been that way for a decade. Probably because not writing a blog entry is the way to avoid work load with the least palpable impact... Perhaps you could try selling blogging support as a coaching bundle. 2 hours consulting for topic selection, 2 hours for you creating a draft, a boss-approved deadline to get it edited for technical correctness by one of your client's specialists and two more hours for finalizing the wording and guiding them through the input. Three or four of these and the usual arguments/excuses (we don't have a fitting topic right now; our current topics are too technical; I've put it on the boss' stack but not heard back; we're waiting for [the release of product X|the traide fair|Christmas]) should be defeated. Some of the big misconceptions I've often found at clients are that writing a blog entry is easy and that obviously blog-worthy topics come up on a daily basis. It's always a steep learning curve for most to accept that you can't just quickly write a blog entry when you feel like it; you have to collect ideas and images beforehand and stick to a schedule blog entries are different from structured site content; writing them is a more creative process you often have to cut corners and sacrifice technical details to keep a blog entry interesting, so you often need two people to keep a balance there blogging takes time, too good blog content holds incentive value, be it because it's humorous or touching or because it has interesting information hard to find elsewhere a blog is not a company history; nobody wants to read plain facts there, so the writing needs to have a personal touch a good blog is a bit like an ongoing novel; it needs cliffhangers and suspense to keep readers' interest. Teasing them with upcoming products and events requires the client to have a reliable timeline for these though4 points
-
You can set a default template by supplying the GET parameter “template_id”, or the POST parameter “template”: http://example.com/processwire/page/add/?parent_id=1024&template_id=46 I’m not sure about forcing the template. You could probably specify a default name format in order to bypass the page-add screen directly, or hook into ProcessPageAdd to manipulate the form.3 points
-
Everyone seems busy and I'm sure image compression will pop up again soon. I think it's a great start. Even if there was only a small declared monetary commitment and a high level technical discussion, I'm sure many more are interested as either backers, developers or designers. BTW while I'd love to see image compression integration, what I'd really love to see is improved cropping options. And by that I mean more integrated first.3 points
-
This module allows users to subscribe and unsubscribe to a newsletter, it doesn't handle newsletter creation and delivery (I use a foreign service for this). There is one method to subscribe (by using a form) and there are two methods to unsubscribe (by using a form or by providing a link in the newsletter). Furthermore you can notify any person e.g. an administator via email when an user has subscribed/unsubscribed. For detailed information have a look at Github.2 points
-
BBEdit is no IDE and not for windows... But ones in a while I have to spam about this editor. It's a real solid editor and the developer is just awesome. He deserves it!2 points
-
Just in case you didn't see, the (fabulous, super-helpful and extensive) docs and examples @kongondo provided are here. Current status: reading with a grin2 points
-
Stumbled pass this completely by accident, though I could see plenty of uses for this in previous projects I've done. I think for 3.0 the Documentation could do with a major refresh. It would be great to put maybe a team together to work on this. I'll be happy to chip in.2 points
-
Same here before PW had not a real understanding of OOP. It was more like: If I do this, i might expect this. Let's trial and error that one out.2 points
-
My opinion: "it doesn't spoil your carma. You just show you're not afraid to be 'ignorant' in the open. That is a state where you show the others: 'I want to learn' and that is quite a strong one. --- The reason it just works is just that User is extending Page, so User is a page with a few extra methods and stuff.2 points
-
@Tony, It seems you are using (or copied from) the demo template files that are optionally installed with Blog. In this particular case we are dealing with blog-post.php. The code that generates that sidebar is found between lines 24 - 35. The method spewing out the markup is renderNav() (line #35). As a quick btw, the general rule of thumb is rather than using CSS to hide markup, first check if it is possible not to output that markup in the first place . In our case, it is possible. Line #31 of the code is what is outputting the Author's name and URL. All you need to do is comment out that line, as well as earlier variables building up towards that code, i.e. lines 25 ($authorsURL), 27 ($authorURL) and line 28 ($authorName). I'm not sure you've seen my earlier posts about documentation (it is a long thread after all), but I used to have Blog's documentation hosted on my website, which is currently in deep hibernation until I get time to revive it. Thankfully, the good guys over at wayback machine archived my now asleep and offline website including all the Blog tutorials. These can be found here and the documentation for renderNav() is here. As you'll see, you can use renderNav() to output all sorts of stuff. Hope this helps2 points
-
edit u. index.php file + add 2 top on.line afters namespace $_SERVER['REQUEST_URI']=str_replace('index.php','',$_SERVER['REQUEST_URI']); when.u no needs index.html no more rember to deletex that ok2 points
-
Background - I came across http://www.responsivebreakpoints.com/ the other day and thought it was a nice idea, but that could be done in PW using the API. In a nutshell, what it does is create an image width breakpoint at roughly every 20kb of file size between a minimum and maximum pixel size. According to this article on CSS-Tricks, "If you’re just changing resolutions, use srcset", so the markup is as suggested there. There is already the excellent Srcset Image Textformatter which works on images in RTE fields, but if you want responsive images elsewhere in your templates, you need to do the markup and decide on breakpoint sizes yourself. However, Field Templates have got you covered! Just save this as a field template file in /site/templates/fields/my_image.php as described above. <?php $maxWidth = 1000; //largest breakpoint $minWidth = 200; //smallest breakpoint $srcQuality = 40; //jpeg quality of the 'src' image $srcsetQuality = 80; //jpeg quality of the 'srcset' images $breakpointStepFileSize = 20; //i.e. 20kb $class = ""; //change this if you want to add eg "class='responsive'" $horizAspect = $value->width / $value->height; $minSizeArea = round($minWidth * ($minWidth / $horizAspect)); $maxSizeArea = round($maxWidth * ($maxWidth / $horizAspect)); $areaDiff = $maxSizeArea - $minSizeArea; $minFile = $value->width($minWidth, array('quality' => $srcsetQuality)); $maxFile = $value->width($maxWidth, array('quality' => $srcsetQuality)); $minFileSize = $minFile->filesize; $maxFileSize = $maxFile->filesize; $fileSizeDiff = $maxFileSize - $minFileSize; if($fileSizeDiff > ($breakpointStepFileSize * 1024)){ $numBreakpoints = round($fileSizeDiff / ($breakpointStepFileSize * 1024)); for($s = 1; $s < $numBreakpoints; $s++){ $breakpointStepArea = $minSizeArea + (($areaDiff / $numBreakpoints) * $s); $breakpointWidth = round(sqrt($breakpointStepArea * $horizAspect)); $breakpoints[] = $breakpointWidth; } } $src = $value->width($maxWidth, array('quality' => $srcQuality))->url; $min = "$minFile->url {$minWidth}w, "; $out = "<img src='$src' srcset='$min"; foreach($breakpoints as $breakpoint){ $bp = $value->width($breakpoint, array('quality' => $srcsetQuality))->url; $out .= "$bp {$breakpoint}w, "; } $out .= "$maxFile->url {$maxWidth}w"; $out .= "' alt='$value->description' $class>"; echo $out; Then use something like echo $page->render->my_image; in your page template and you'll get something like <img src='/site/assets/files/1/photo.1000x0.jpg' srcset='/site/assets/files/1/photo.200x0.jpg 200w, /site/assets/files/1/photo.482x0.jpg 482w, /site/assets/files/1/photo.651x0.jpg 651w, /site/assets/files/1/photo.785x0.jpg 785w, /site/assets/files/1/photo.899x0.jpg 899w, /site/assets/files/1/photo.1000x0.jpg 1000w' alt='pic' > (Bear in mind that PW has to create all these image variations on first page load, so it will take a moment.) Give it a try and see what you think!2 points
-
Good news! We were chosen by the product hunt team to be featured in their permanent list, and we are now on their homepage with the other tech products of today Any of you has a nice animated gif that shows the admin? Would be great for showing off!2 points
-
Warning: Still a work-in-progress. Still has quite a lot to be done. At Tom Reno's request I started work on a module that allows you to setup various watches on fields in your PW installation. You get to choose a field and can then specify when a change to the watched field should trigger a notification email to various interested parties. Pictures might help, so here we go... I intend adding a further restriction so fields in certain templates can be watched.1 point
-
Finally, I got spared some time to work on a project I have been meaning to do for a while. This follows on from this request and other discussions about the pros/cons of an ApiGen for ProcessWire. I am all for such docs as long as two conditions are met: (i) That it is clearly indicated who the target audience is; and (ii) that the docs are regularly updated. I think this project meets both. I have created a GitHub project and project pages for hosting regularly auto-updated PHP ApiGen Docs for ProcessWire 3 (master and dev) as well as ProcessWire 2.8 (master). We also have ProcessWire 2.7 (master and dev) docs but these are not updated since this version of ProcessWire is no longer active. The whole doc-generation process is automated including auto-pushing changes to GitHub. The current cycle is: ProcessWire 2.8.x Master branch docs: updated once at the beginning of every month ProcessWire 3.x Master branch: updated once at the beginning of every month ProcessWire 3.x Dev branch: updated once weekly, every Friday Docs are generated for all .php and .module files under /wire/core/ and /wire/modules/. Currently, this is all done via my home PC. I am on a Windows machine so nothing could really go wrong... . Barring the unforeseen, these docs should be roughly in step with the latest ProcessWire commits. Now running on a remote server. Tools used Windows PowerShell (move over wget! ) wget Git-Bash Windows Task Scheduler (there's your cron right there ) cron Pear APIGEN Scripts: PowerShell, Bash Script, VBS and Batch files A couple of stress balls I hacked together a dark theme for this project, sublime-text default look. The CSS still needs some work, all help appreciated, thanks. If anyone would like to create an alternative theme, we could incorporate a theme switcher. Feeback, thoughts, suggestions (e.g. text in READMe, etc)? Credits to Ryan for writing such well-commented code...otherwise this project would not have been possible. From the READMe1 point
-
This ProcessWire module allows you to import and parse XML files (using xpath) to create or update pages. [detailed instructions at github] Settings After successfull installation go to Setup > Import Pages From XML to start using the XML Importer. This module does not support all available field types. Nevertheless, I've refrained from restricting the supported field types because many of them should work by default. Xpath Mappings If you want to take advantage of references between fields in your xpath mapping then make sure the fields you're relating to are placed before the ones which need the relations. You can access and use any values/fields that you placed earlier in your file. Use $field_<fieldname> to match the desired value. Example: <?xml version="1.0" encoding="UTF-8"?> <songs> <song track="2"> <title contact_id="1">Some song title</title> </song> <song track="7"> <title contact_id="2">Just another song title</title> </song> <contact id="1" name="Sesmallbos" mail="info@test.org"/> <contact id="2" name="Sebigbos" mail="info@exam.ple"/> </songs> context: //song field order: title, track, contact_id, contact_name, contact_mail contact_id must be placed before contact_name and contact_mail first get contact_id : title/@contact_id then use that value as relation : //contact[@id=$field_artist_id]/@name as well as //contact[@id=$field_artist_id]/@mail1 point
-
I posted this here https://processwire.com/talk/topic/11998-growing-processwire-in-2016/?p=111884 but I thought it would be better to open a new thread to catch the attention of more people. Today I submitted PW to Product Hunt. https://www.producthunt.com/tech/processwire This is a site with great exposure, but only if PW gets featured on the homepage. For this it has to be reviewed by the Product Hunt team and one of the most important factors is the number of upvotes. So, what are you waiting for? Why are you still here? Edit: If anyone would like to suggest different pictures for the header and thumbnail, go ahead.1 point
-
Check this example by Ryan himself, I think this form is as simple as it gets, pretty much in a regular PHP way, but using PW API to make it all a lot nicer. This other post by Soma has insight on how to create a Page and save it. You just need to put the data from your form into the fields.1 point
-
Edit your first post with the "Full Editor" to change the title. But I'm not sure if you should change the title as the repeater analogy is far more fitting than the table one. ProFields table does not hold other fieldtypes – it's merely using inputfields to let you edit a database table "a bit more comfortably". That's why the field selection and setup differs so much from the real fields. Repeaters or PageTables are really grouping fields (in templates) and make them reusable in other templates, but with the added feature of repeatability. So to conclude, the fieldtype you're looking for is already available. It's the page field in single page mode. It's just that there's currently not a inputfield that would allow for a seamless integration of a page in a page.1 point
-
some recently launched pw-powered sites... Roger Shapiro Fund for New Music Custom blog & news, projects listing and works w/ dataTables... using Soma's social share for the sharing buttons http://www.rogershapirofund.org/ Daniel Lippel, Guitarist http://danlippel.com/ Flowers by Selina Website for floral designer in Westchester, NY. Features custom blog, homepage featured portfolio and full masonry portfolio. http://www.flowersbyselina.com/ Eric Huebner, Pianist media handled by Soundmanager2. A frontpage ajax-powered widget was implemented to let visitors browse the concert & event calendar, with a browsable month view. http://www.erichuebner.com/ Anderson Chase Gallery Simple one-pager http://andersonchasegallery.com/1 point
-
the blog i setup for 2 of the above has a lot of standard blog features like categories, tags, archive, feeds, comments etc; it was no small effort to set that up, but once i had the basic setup i reused the code; i didn't use the blog module, since i predicted that they would actually never use it, and i didn't have time at that phase to integrate a module, i just did it quick with pages and page selects..1 point
-
1 point
-
Dank je wel Martijn voor dit snelle antwoord. Unfortunately I forgot to mention that I'm on windows 10 ...1 point
-
...just a quick edit : <?php $num = count($page->comments); echo "<p>Page has $num Comments</p>"; ?>1 point
-
Not sure if wireshell does allow for that, but if not you could go that way. > php -a php> include "index.php"; php> $pages->find("template=some_template")->each(function($p){ $p->setAndSave("field", "value"; });1 point
-
It's probably just an oversight, so you should open an issue for it. In the meantime, you can fix it per hand by changing this line in FieldtypeComments.module's find method (around line 1000): if(in_array($f, array('id', 'status', 'created', 'pages_id', 'parent_id', 'created_users_id', 'upvotes', 'downvotes'))) { and add the stars field: if(in_array($f, array('id', 'status', 'created', 'pages_id', 'parent_id', 'created_users_id', 'upvotes', 'downvotes', 'stars'))) {1 point
-
Oh, always forgot that not all systems are fully configurable1 point
-
Can't you just do this? $selector = ("page=$page, sort=-created, start=$start"); // Comment selector $comments = FieldtypeComments::findComments("comments", $selector); //comments is the name of the field foreach($comments as $c){ // Only output those with 5 stars if($c->stars == 5) { echo "Stars = " . $c->stars . "<p> By: " . $c->createdUser->name . "</p>". "<p> Comment: " . $c->text . "</p>"; }1 point
-
Just in case you don't know, there is a setting under your forum profile for automatically following topics that you post to.1 point
-
I've decided to make a start on the design, I thought I'd get a feel on what people think about the idea behind me doing this before continuing. I've always been passionate about UI/UX, and I'm always up for the extra practice wherever I can get it. Here is the design I've started: (http://i.imgur.com/2SY50ua.jpg - full size) So here are few things I've tried to solve with this: Unify the user journey, this page tree is going to be the main focus for every user and often unless you are an admin, the sidebar doesn't get used often. This is great from a UX point of view because that means they know exactly where everything is and there is no complicated bloat. I've tried to move very useful features into this screen as this is where I find users spend the most time. Also giving admins the ability to better define that user journey. The cog will edit the filter and the add filter button will, well, add a filter. Filters will work much like Peter mentioned ListerPro, however they will work just as well with Lister. I will do a mock-up if people want on how a filter page will look. The other people is moving items in the page tree. Many people expect to be able to drag and drop and if they want to move into a child and didn't open the page tree first. Then they will have to stop the move, open the tree and then move again. This works by hovering over a parent, the child will then expand. You can start a move just by dragging the page name. Another people I've seen people do, is not knowing to click on the edit on the right of the page name. Instead they frantically click the page tree and watch the page name highlight change, but nothing happen. I hope to do some work on this, but part of the problem is that the page names look like links. However I think they should be clickable to go into edit. I see people doing it, so they must feel natural doing it that way. I haven't yet thought of a solution for this as I also like how the click expends children. However one thing I've thought of is have it click it edit if it doesn't have children. If it does the will have to use the edit as normal. I'm not completely sold on this idea as I don't like the idea behind having two ways to get to edit. I can see this confusing users. Advanced Search will be the same as Lister.1 point
-
Just a few thoughts: I'd go with the legacy GeoIP databases and use geoip_country_code_by_addr (and optionally its IPv6 sibling). This should only be a few lines of code, plus, depending on the server you're running, perhaps a few more lines to download the current database every month (AFAIR, some Linux distributions even provide packages with cron jobs for that already included). Don't waste too much time trying to find the optimal solution by looking at browser headers etc. - those solutions don't exist. People surf through foreign proxies, use their en-gb browser on a trip to the U.S. or surf the U.S. page from an internet cafe in the UK. Make sure to avoid annoying the users. Embed the pointer to the native site in a prominent but pleasing way in the page, don't disturb them with javascript popups (modal or not). The first time, they'll click it away. The second time, they'll sigh and click it way. The third time... Whatever you do, never redirect a user automatically just because you think you know their origin or preferred language. They may well have a reason for wanting to access the URL they've entered or clicked. Instead, add a language switcher that lists all languagues/countries in their native language (the latter is not much of a point for U.S./UK/Ireland, but for the sake of completeness, I'll mention it here).1 point
-
Just wanted to say that this sounds very interesting. Been meaning to build a module like this, though was thinking of limiting it to PNGs since that seems to be the only case where optimization doesn't necessarily mean sacrificing quality. I'm also aware of the minimize.pw service, but a) it's not free (as in beer or as in freedom), b) it doesn't seem to be well maintained and c) I don't want to rely on external services unless I really trust them (especially when it means sending client data over to an external server). As a reply to Horst, kind of, I'd like to point out that whether or not the host allows exec(), if there's a similar solution that doesn't require it, that's in my opinion always the better route. Even when you're taking every step to make sure that it's safe, exec() is still potentially dangerous. Any and all mistakes have the potential to compromise your entire server (or, at the very least, your personal account). There's a reason why exec() and other code execution methods tend to trigger warnings from security scanners. That being said, I won't deny that executing external apps via PHP can solve some situations where nothing else helps. I've had to use it many times over myself. Edit: just took a closer look at Tinify. Somehow I managed to miss earlier the point that it is also an API, i.e. requires sending the data to their servers for processing. Can't say that I would be exactly happy with that, but will give this a while; perhaps it's a compromise worth making. In the meantime I'll be looking into some alternative approaches.1 point
-
That would lead to a delayed output from a beginner - if any output at all1 point
-
Yeah just read it. Since I came across the delayed output (and using leading underscore for view files) I fell in love with it. Set variables (or placeholders as some call it) with init values, output them in _main.php, give them overrides as needed in a template file. Use wireRenderFile() for view files. You can in fact stack your site with any layers you want, outputted in _main.php1 point
-
For those concerned about security, you could do this afterwards on Twitter: I can confirm your vote is still there afterwards.1 point
-
1 point
-
I registered with my normal twitter account and voted +1. I do not know how they use those valuable bits of private info about me, but not sure they can do something worse than twitter itself)1 point
-
Thanks for going through all that effort guys! Yep, the same happens all the time to me with facebook.1 point
-
out for this. Isn't there another way to upvote for processwire without spreading my private data around ? i alsos donut like.to spread my.privates a round withs tweetster u.can jus make throws away acct to uses.for this stuffs butt fecesbook tweetster and friendsters blocked in.my cuntry butt i stil haves myspaces butt no work w produt hunter butt at lest not blocked .i keep try to make work1 point
-
I wasn't talking about having this done on demand. No matter when this resizing does happen it's a hit on the server's resources. Even generating the one thumbnail for the admin backend (on upload) can take around a second, not talking about multiple thumbs per file. Imagine someone throwing 10 images in the image field and going to grab some coffee before he can continue. As always it's up to the individual to implement such a system on their own if really needed.1 point
-
A task is something that needs to be done, e.g. sending an email at the end of someones buying in a shop. Sending the email is the "task". You can use this module for what ever you like. It is really very basic. If you has setup one Queue, you can access it (like in the code snippet in the first post) from a template file or from within a bootstrapscript. You need to know the name or id of the page that holds the Queue, thats all you need. Than you can pass data records to it. With the textfile storage every data record should be an array. I don't know if this can be useful for your import script. Definitely a Pro would be if you are limited with script execution time by the server. Then you can scan / read in all needed pages / images and put them into the queue without starting to process them. After you have finished this read in, you start processing them by pulling out items from the queue as long as you are within the time limit. If you reach critical time, you stop processing and end the script. It needs to be reloaded somehow, e.g. could be done without any cron but via session->redirect() as last command that ends the script. This way you strat with a fresh amount of execution time. No record gets lost as it could be if you use only session for storage. Maybe, you know the name Stack? It something similar as a Queue. Difference is, in a Queue is something like a pipe with both sides open. What is put in first, gets pulled out first at the other end: FiFo (First in First out). A stack is something where you put one item upon the other, maybe also a pipe, but with one end closed. Therefore you can only pull the last item from it, not the first: FiLo (First in Last out) WireQueue module is nothing more than the basic implementation of it into PW. ?? Ok ?? If you are unsure if this can be useful for your >cron task<, maybe you can explain a bit how this is be done. From where and when do you get the items that needs to be imported and how do you process the images and what is the next step, etc.1 point
-
Hey guys, this upgrade now appears on PW 3.0 (devns) branch. If you are using the ~= operator in a search, like "title~=disability act" it now asks MySQL for the ft_min_word_len (per @LostKobrakai's suggestion above). If any word length falls under that threshold, it delegates that word to a separate REGEXP command in MySQL that matches whole words. This is actually an improvement over the code I mentioned earlier because the previous code that converts it to use a "%=" for short words could match things like "disability fact" or "react to this disability" etc. Whereas the new core addition will only match whole words in the same way that the MySQL index would, meaning the field would only match if it contained the exact words "disability" AND "act" somewhere in the field, and not some word that happens to contain the partial word "act". To take it further, it also now uses this technique to match stopwords that MySQL doesn't full-text index. Previously it would just exclude them from the search since the presence of a stop word would prevent a search from matching. Now you can perform searches that include those stop words and match them.1 point
-
It's not good to reinvent the wheel, but it's not bad to know how wheels are made. What you want to do is actually quite simple, and all you need is a loop inside the first loop. For only two levels, a very simplified version could look like this: echo "<ul>"; foreach($homepage->children as $item) { // loop through the children of root echo "<li><a href='$item->url'>$item->title</a>"; if ($item->numChildren(true)) { // check if this item has children echo "<ul>"; foreach($item->children as $sub_item) { // loop through the children of each item echo "<li><a href='$sub-item->url'>$sub_item->title</a></li>"; } echo "</ul>"; } echo "</li>"; } echo "</ul>"; For more levels, you could keep adding loops inside loops, but then, it would make more sense to make a recursive function (a function that calls itself while there still are children). One more thing. In your code you add the id for the current page like this: if($child->id == $page->rootParent->id) { // this $child page is currently being viewed (or one of it's children/descendents) // so we highlight it as the current page in the navigation echo "<li><a href='$child->url' id='current'>$child->title</a></li>"; } else { echo "<li><a href='$child->url'>$child->title</a></li>"; } You can avoid repeating code by doing this instead: if($child->id == $page->rootParent->id) { $current = ' class="current"'; } else { $current = ''; } echo "<li><a href='$child->url'{$current}'>$child->title</a></li>"; Or, more compact: $current = $child->id == $page->rootParent->id ? ' class="current"' : ''; echo "<li><a href='$child->url'{$current}'>$child->title</a></li>"; You can also replace $child->id == $page->rootParent->id by $item == $page for the current page and use rootParent to give the class to the parent item only1 point
-
Folks, I just uploaded a new test branch for this module to github that adds the ability to spit out alternative texts on each parse. The idea comes from products like spintex and allows you to use one text block to generate different output on every view. Basically you write stuff like "Dear {{mum|dad|grandma|grandpa|Ryan}}, ..." and the textformatter makes a choice from the listed alternates at every point in your text. You can control the degree of randomness and I'm playing with setting it based on a cleaned up version of the referrer URL to make visits from different places have different versions of the text but repeated visits from the same place see a consistent version of the text. In other words, people coming from google will see something like "Dear dad, ..." each time they visited whilst those from Yahoo would see "Dear Ryan, ..." when they visited the very same URL (at least, that's the plan.)1 point
-
Actually i found the answer $num = count($Page->comments); "<p>Page has $num Comments</p>"1 point
-
This is possible Create a field of type "FieldsetOpen". In your template, just sorround your fields you want to wrap in this fieldset with the fieldset created. //Example for fieldset with name "fieldset_advanced": fieldset_advanced date summary fieldset_advanced_END Btw there exists also a "FieldsetTabOpen", which displays the wrapped fields in a new Tab1 point
-
I've just added it to ProcessPageSearch and committed the update to the P21 source. Now you can do something like this: var url = config.urls.root + 'page/search/for?template=basic-page&body*=something'; $.getJSON(url, function(data) { console.log(data); }); The example above shows "search/for?" as the URL. When you add the "for" to it, it assumes that you are going to specify a selector in the URL. This works with either Ajax or regular mode. In ajax mode, it returns JSON. In regular (non ajax) mode it's going to output the results in interactive/html mode as usual. This "selector mode" isn't used in the search engine by default, so it's only used when you include the "for?" in your URL and specify a selector after it. I believe this selector mode is much more convenient than the regular mode for AJAX use, as well as regular non-ajax links to the search engine. The selector can be identical in format to a regular selector with the only difference being that you separate each part of the selector with a "&" rather than an ",". Here is an example: /processwire/page/search/for?template=villa&body*=luxury&bedrooms>5&bathrooms<=3 The above is a valid URL, but it's also a valid selector. If we replace the "&" with ", ", then we get this: template=villa, body*=luxury, bedrooms>5, bathrooms<=3 PW abstracts away the parsing of GET vars that lack an equals sign, like "bedrooms>5", and translates all of PW's 2-character operators just fine too (like *=, ~=, %=, <=, >=). Of course, you can also do this (specify a parent path): /processwire/page/search/for?parent=/path/to/parent&featured=1 If you want to specify what fields should appear in the JSON output (or the interactive table), then just add a "get=" var to your URL, like this: /processwire/page/search/for?template=basic-page&get=title,path,categories Separate out the fields you want to "get" with commas, like above. When you specify what fields should be included, it will include them in the output, in addition to the native fields that are included in all (like id, name, template, parent, etc.). Because JSON can represents objects nicely, PW will also include partial objects (like page references) as JSON objects. For something like a Page reference, it'll include most of the native fields for each page, as well as the title and path. By default it will paginate by 50, though you can increase that up to 250 by specifying your own "limit=123" var in the URL (where 123 is the limit you want to specify). To retrieve the next pagination, specify the same limit but precede your URL with the page number, i.e. /processwire/page/search/for/page2?template=basic-page&limit=100 If you prefer, you can specify a "start=123" var in your selector (just like with other PW selectors), to indicate the result number you want to start from. But I'm guessing most will prefer the simplicity of using the page number pagination. If you call jQuery's getJSON() on the search URL, you will get your results in JSON format. Here's an example of a call we might use: $.getJSON("/processwire/page/search/for?template=basic-page", function(data) { console.log(data); }); jQuery's getJSON automatically converts it to an object in jQuery, but the JSON string is probably the simplest way to envision it, so here is the actual JSON string as it's returned from that query. This query was performed on a stock install of PW 2.1 using the included profile. <?php // ignore the PHP tag, I just wanted syntax highlighting { "selector":"template=basic-page, limit=50", // just a repeat of the selector you used "total":"4", // total number of results found. if there were 1230 matches, this would be 1230 "limit":50, // the max number of results that will be in this request (default=50) "start":0, "matches":[ // array of matches { "id":1001, "parent_id":1, "template":"basic-page", "path":"/about/", "name":"about", "title":"About" // plus any fields you specify with get=... }, { "id":1002, "parent_id":1001, "template":"basic-page", "path":"/about/what/", "name":"what", "title":"Child page example 1" }, // and so on for each match ] } I'm sure there are tweaks and improvements still to be made, so please let me know if you find any issues or areas for improvement.1 point