Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/05/2014 in all areas

  1. Marek747, All languages have their ups and downs. "Language X is better than language Y" is just about as far from valid argument as you can get. For an example, if speed is your first goal and popularity second, it would make most sense to forget node.js, RoR, and any given framework for that matter (they always add some extra overhead) and go with plain C instead (although that's just about as "old-school" as you can get). C is widely acknowledged as one of the most popular programming languages (TIOBE, IEEE Spectrum, etc.) and it's definitely the go-to language if you want superior speed. That being said, web applications built on top of C are (to my best knowledge) very rare, and some developers would argue that it's not exactly an easy language to master. Just for comparison, something like Ruby (and Ruby on Rails, which is a framework you mentioned) is designed from a very different point of view: it was originally known to be very "hip", very comfortable to work with.. and extremely slow. (I'm assuming they've improved those figures since then – that was quite a while ago – but Ruby is still hardly your best choice if you need top notch performance.) If you want a language that's comfortable to work with, good for web application development (I'm assuming that's why you're here), and widely supported, go with PHP or Python. PHP is more widely used, which makes it a good choice. It's also ugly, inconsistent, etc. but a lot of developers have learned to live with those flaws because it's good at what really matters: getting shit done. Note: I'm not saying that JavaScript and/or node.js is a bad choice, but they're not quite as popular or well-established yet, and the future of the web is bloody hard to predict. It's definitely good to have knowledge of them, but in my opinion they're not quite there yet. Perhaps one day they'll power all the popular apps around, or perhaps they're a fading trend, nobody really knows.
    10 points
  2. Greetings, Ah, the code war sees a battle here on the PW home front! This has been raging on for a long time. You don't have to choose all or nothing with languages. My own history is with C/C++, and over the past year I have been spending time learning Python. After a while, you start seeing the same underlying principles in each one. PHP is perhaps more "messy" than other languages. You don't have the same level of agreement in PHP as you see in the Python, Ruby, Java, or .NET worlds. All of those other languages have rallied around a set of conventions, frameworks, and more. Fewer conventions and many more frameworks makes PHP more confusing at first. But that's also what makes PHP so lively and flexible. Thanks, Matthew
    6 points
  3. Why did Ruby needed the Rails framework to become very popular? Why do Google developers love PHP. Does NodeJS stays popular in the future, say 4 or 5 years? Why is facebook coded in PHP? What's wrong with PHP?
    5 points
  4. Uh? Old school is not always bad school
    5 points
  5. I don't fully understand why you want to have static class names attached. The lightbox is javascript, so you could solve it with jQuery for example. $('a[href*="/assets/files/"]:has(img)').addClass('lightbox-class');
    5 points
  6. This sounds like a very easy thing to implement using the PW API. Do you want to log all the pages the logged in user visits, or just monitor one particular page? You could certainly make use of Profields table to create a user visit log. In fact I use it already for a similar purpose. Hopefully this will get you going. This assumes you have a page called visits and a Table field called visit_log with table sub-fields called date, user_id, and page_id $visits = wire('pages')->get("/visits/"); $visits->of(false); $visit = $visits->visit_log->makeBlankItem(); $visit->date = date("Y-m-d"); $visit->user_id = $user->id; $visit->page_id = $page->id; $visits->visit_log->add($visit); $visits->save("visit_log"); PS You might want to make this Table field not editable (locked), or maybe even hidden from the editor as it will likely become extremely long and might have issues when displayed in the PW admin. Something else to think about - you could add this field to a site-wide "visits" page like in my example, or have it attached to every page of interest on the site and then you wouldn't need the page_id subfield.
    5 points
  7. @Craig A Rodway. You are truly a Distinguished Member. That works well. Thank you for you help. You can see the live json calendar in action.
    4 points
  8. PHP is default on most shared hosting servers nowadays. It is much easier and cheeper to get a site running than with NodeJS, for example. So it seems like a better choice for SMB and therefore developers that just start their career as freelancers.
    4 points
  9. 4 points
  10. Ah yes there's no support for subfields, only the page field will replaced with url. But you could custom replace a placeholder with a hook. For example name the placeholder something like "color" can be anything. Then add a hook like $nav = $modules->MarkupSimpleNavigation; $nav->addHookBefore("getItemString", null, function($event){ $tpl = $event->arguments("tpl"); $page = $event->arguments("page"); // maybe some condition do whatever you need if($page->catColor){ $tpl = str_replace('{mycolor}', $page->catColor->title, $tpl); // replace the placeholder $event->setArgument('tpl', $tpl); // send back the tpl argument } }); // then render as usual using the {mycolor} echo $nav->render(array( 'item_tpl' => '<a class="{mycolor}" href="{url}" title="Link to: {title}">{title}</a>', )); The method getItemString() is just the method that runs a parser to replace the placeholders with real values, so we hook into it before.
    3 points
  11. If I would start I would start with pure Javascript or with PHP. Then if the basics are there, you could expand. When first riding a bike training wheels are necessary, put them off when you're ready.
    3 points
  12. Hey guys, wow - I did not expect the community to be that active.. One reason more to love PW Thanks for all the suggestions. I like the idea of reducing the field name to 'publish'. Seems a lot more consistent. I'm not sure about this publish-unpublis-publish scenario. I guess the only situation where you would want the publish date to change is when you published by accident. Making this optional could work, but it should be on page level then. At least I would not want this behaviour for all pages. And yes, that could definitely be tedious.. What about simply making the publish field visible and editable? It is hidden by default (if created by the module), but that can be changed easily. That way you could simply change or reset the publish date if you hit the button too early.
    3 points
  13. Because it's not that easy for the average user to setup a nodeJS environment, I guess.
    3 points
  14. So I ended up fidling all day and I am happy with the results Just took a bit of looping, really tested my skills:) Here is a code chunk to get you goin //this block counts artists in relevant category based on $dept var set above. //it then will set the amount to be shown per column and how many columns to display based on count if ($dept = "Contemporary"){ $select = "artwork_dept=/departments/contemporary/"; $count = count($pages->get("/artists/contemporary/")->children($select)); $initCount = $count; $entriesper = ceil($count / 4);//entries per line $artists = $pages->get("/artists/contemporary")->children($select); $artists = $artists; echo $entries; }elseif ($dept = "Modern"){//todo make the actually work $count = count($pages->get("/artists/modern/")->children("artwork_dept=/departments/modern/")); }elseif ($dept = "Antique"){//todo make the actually work $count = count($pages->get("/artists/modern/")->children("artwork_dept=/departments/antique/")); } //grab chunks of artists $i = 1; $firstInRow = 0; $mod = $count / $entriesper; while($i<$entriesper){ $out .= '<div class="col-md-3">'; $sliced = $artists->slice($firstInRow,$entriesper); $firstInRow += $entriesper; $out .= '<ul class="artist list">'; foreach($sliced as $artist){ if ($artist->artist_featured_image->url){ $img = $artist->artist_featured_image->width(175)->url; } $fullname = ""; $fullname = $artist->artist_firstname.' '.$artist->artist_lastname; $link = $artist->url; $out .= '<li><a title="'.$fullname.'" class="preview" href="'.$link.'" rel="'.$img.'" >'.$artist->artist_firstname.'<strong> '.$artist->artist_lastname.'</strong></a></li>'; } $out .= '</div>'; $i++; } $out .= '</div>';//end row echo $out; ?>
    3 points
  15. Thanks for this - looks great. What do you think about the situation where a page is published, then unpublished, and then published again. I think your current behaviour is probably fine, but just wanted to see if anyone else has any thoughts on whether the initial date should be preserved or not? What about including a published_users_id as well? This actually brings me back to Nico's suggestion of calling the field "published". That way we'd have: created created_users_id modified modified_users_id published published_users_id Actually, any thoughts about whether it would be better to extend the pages database table to include these fields directly, rather than as separate custom fields? Maybe that's not a good idea for some reason I haven't thought of yet - anyone have any thoughts on this?
    3 points
  16. Its a nice little bit of real life: "Hey, information? I lost my socks." "They are behind the sofa" "Thanks." With data, there should always be the equivalent of "behind the sofa" somewhere.
    3 points
  17. Hello, I created a simple REST helper in order to create REST APIs with Processwire, without depending on external routers Here you go!. https://gist.github.com/clsource/dc7be74afcbfc5fe752c
    2 points
  18. Super Smartypants is a ProcessWire textformatter module which adds support for languages. It also allows you to set the different Smartypants Typographer parser attributes to customize which rules apply and fixes some bugs. Super Smartypants requires the language module. Usage After installation, add /site/modules/TextformatterSuperSmartypants/smartypants.php to your language translations. To enable Super Smartypants for a language, set the Smartypants attributes field to 1 (or see below for details), otherwise to disable leave the field empty. Change default strings according to your masterful typographic knowledge. Documentation and download : https://github.com/plauclair/SuperSmartypants
    2 points
  19. I actually went now with: jQuery('a[href*="/assets/files/"]:has(img)').fancybox(); because I didn't like the idea of altering the dom only to apply another javascript. So in the end, it is like I wrote in my initial posting But the different-thinking-approach led me there, great work Martijn! I'm still thinking about adding a static class to every image inserted with CKEditor so I could identify these images and change their appearance with CSS. For this I now have Nicos solution, just perfect!
    2 points
  20. muzzer, Your scenario is exactly what Migrator was designed to do. It does not migrate page IDs at all. Every reference to an id gets converted to a name/path on export and a new page id created on import to the new site. I would still recommend testing the migration to a test PW install first until you have a full understanding of all the import settings and how they can affect the import. Also when you do it to the live site, please make sure to backup your database first. This module generally works as advertised, but there are some weird scenarios like what Macrura experienced with a page field that points to users that can cause problems. I will be fixing this shortly - I just need some more info from him. Please let me know how it goes for you and if you think of any possible improvements in the way it works.
    2 points
  21. In answer to the original question: Imo in the open source world a lot of the Content Management Systems are build with PHP, because, despite its shortcomings, it is: A) a pretty good fit, with a low entry level, B) has a long history in the web world, C) due to various reasons PHP has an insane presence in the shared hosting world compared to any other language. In the world of the more 'enterprisy' and/or closed source CMS'es i have i feeling there are more Java or C#/VB ASP.NET systems out there. When it comes to a general purpose CMS/CMF, Node.js is not the first thing that comes to mind. Commonly mentioned use-cases for Node are real-time applications, like a chat app, or building heavily used API's on top of maybe a nosql document store. That is not to say there aren't any Node CMS'es around.
    2 points
  22. Old school PHP, say what ? Then why is PHP powering so much of the internet? http://www.phphosts.org/blog/overview-of-the-php-programming-language/ quote: Modern versions of PHP are object oriented just as modern versions of C/C++ are. In fact, PHPs relationship with the C programming language is so close now that it is possible for developers to write extensions in C to add additional functionality to the PHP language. Edit: How many node.js programmers are wanted compared to php programmers
    2 points
  23. Focus on both. But you will find it much easier to start with pw
    2 points
  24. I'd suggest you learn PHP first [when it comes to server-side tech]...since it is the most popular server-side programming language (>80% of market). On client-side, learn HTML, CSS and some js, or better jQuery ;-)...you can then pick up node.js along the way....but I am biased. Seriously though, it will do you good to learn PHP. It is not going to disappear in the near future (if it does at all)...
    2 points
  25. For the publish-unpublish-republish scenario you could also make it configurable via a "retain publish date when unpublished" option? Because i can see cases for both.
    2 points
  26. @everfreecreative, This has been in the dev branch for a while now: https://processwire.com/talk/topic/3768-processwire-dev-branch/?p=58107 Does that take care of the functionality you are looking for?
    2 points
  27. This should help: $events = $pages->find("template=sectionItem, parent=1025|1066|1073|1069|1013|1247|1101, sort=startTime, start=10, limit=3"); $events_array = array(); foreach ($events as $event) { $start = "".date(strtotime($event->startTime)).""; $title = $event->title; $events_array[] = array( 'title' => $title, 'date' => $start ); } $events_json = json_encode($events_array, true); echo $events_json; The reason is because before, you are simply json_encoding one PHP array at a time into a native javascript object. This way, you are creating the eventual array of objects - first in PHP, and then asking json_encode to work on the whole collection of items.
    2 points
  28. In case anyone is interested in trying out some of the things I was talking about in previous posts here, the latest dev branch has a field import/export function. You'll see it in the lower right corner of Setup > Fields. It enables you to copy and paste any fields across any PW installations. Locally, I also have this working for templates (with fieldgroups), though that part needs a little more work so it's not yet committed. I also have fields, templates and fieldgroups mirroring every change to JSON files, as an option that can be enabled for those that want to version these things with Git and what not. That part also isn't yet committed to dev, but will be soon. However, I figured the copy/paste function probably had the largest use potential. It makes migrating field changes (or creation of new fields) quite a simple task. Next up on the commits will be the same thing for templates (with fieldgroups). (note I didn't take these screenshots together, so they aren't referencing the same fields).
    2 points
  29. @doolak You may try this. I took my code and modified it a little so it may not work out of the box. //parent of your galaries $galleryHome = $page->parent; //all your published gallery pages (make sure you use the same sort option as in your template when output) $galleries = $galleryHome->children; //page being viewed $currentPage = $page; //number of galleries per page $galleriesPerPage = 5; //index of the page in array $PageIdInArray=NULL; //the number of the page your current gallery belongs $pageNum=0; foreach($galleries as $i => $p) { //iterate every galleriesPerPage time if (($i%$galleriesPerPage)==0) { $pageNum++; } // if ($currentPage->id == $p->id) { $PageIdInArray = $i; break; } } //if we found our page in array and $pageNum<>0 if ($PageIdInArray && $pageNum) { //construct url to the galleris landing page $url = $galleryHome->url . "page" . $pageNum; echo "<a url='$url'>Back to galleries</a>"; }
    2 points
  30. Hi moonwhaler, According to teppo's first post:
    1 point
  31. How about <blink><marquee></marquee></blink>? I've always wanted to write a polyfill for that :-D #theGoodOldDays #yesHashtagsInAMessageBoard
    1 point
  32. I didn't see it I think pink is too close to black - maybe we should make the text blink or something on links
    1 point
  33. Hmm.. So there may be conflicts with sites that already have a field that uses the same name as my module. Maybe I should make the fieldname configurable. I guess the fixed name would be fine for a core module, but since this is something you might want to throw into an existing application, it might be a sensible addition.
    1 point
  34. in the beginning me neither got the idea when i edited a page, so i tried it ! on the other hand i want everyone to know, i didn't made any security checks because other modules do this already. i could have integrated them, but i think the original content would be better in use (in case of updates aswell) so what you should use is: somas HideSettings.module (couldn't find it as module but in the forum) ryans PageEditPerUser.module (url : https://github.com/ryancramerdesign/PageEditPerUser/) with those 3 in combination everything should be set and done and the user shouldn't be able to "fool around"
    1 point
  35. sooooo, maybe this is overkill or totally Wrong but i got it to work. offcourse in a module as it should if someone needs this feel free to use: <?php /** * Created by PhpStorm. * User: Blackeye1987 * Date: 04.08.14 * Time: 10:09 */ class CustomStartpoint extends WireData implements Module, ConfigurableModule { public static function getModuleInfo() { return array( 'title' => 'CustomStartpoint', 'version' => 100, 'summary' => "Access Startpoint for Users *needs (type:page | single page or boolean | Input field type PageListSelect+) set to user template* *Consider Taking in Account using ALSO ryancramers PageEditPerUser.module for extended User Control -> https://github.com/ryancramerdesign/PageEditPerUser/", 'href' => '', 'singular' => true, 'autoload' => true, ); } public static function getModuleConfigInputfields(array $data){ $inputfields = new InputfieldWrapper(); $field = wire('modules')->get('InputfieldSelect'); $field->attr('name', 'startpoint_field'); $field->label = __('Starting Point'); $uT = wire('templates')->get('user'); $fL = $uT->fields; foreach($fL as $f){ $field->addOption($f->name,$f->name); } //set your named custom field for the startingpoint of the user $field->attr('value', isset($data['startpoint_field']) ? $data['startpoint_field'] : ''); $inputfields->add($field); return $inputfields; } public function init() { $this->addHookBefore('ProcessPageList::execute', $this, 'startpoint'); } public function startpoint($event){ $page = $event->arguments[0]; //startpoint page $sp_p = $this->get('startpoint_field'); $id = $this->user->get($sp_p)->id; //if no page is set run normally if(!$this->user->get($sp_p)){ return; } if(!isset($_GET['id'])){ $_GET['id'] = $id; } //if user tries to overwrite id, still edit needs to be allowed //--can be handled through ryans module! //do not allow them to edit the pages and you are done if($_GET['id'] != $id && !strpos($_SERVER['REQUEST_URI'],'/page/edit/') > 0){ $this->message(__('You are not allowed here')); return; } //bugfix pw ? //open needs to be removed because: //if open is a childid of id, id will be opened twice (why ?) unset($_GET['open']); $_GET['id'] = $id; if(strpos($_SERVER['REQUEST_URI'],'open=') > 0){ $this->session->redirect(substr($_SERVER['REQUEST_URI'],0,strpos($_SERVER['REQUEST_URI'],'open='))); } return; } } readme: 1: Create new Field : type: Page Details (Single Page or boolean) Input: Select Parent (Home is fine because as admin you set this Value) Input: Input field type PageListSelect 2. Assign to UserTemplate 3. Set Startingpoint for the User who needs the Startingpoint 4. Login with User who should now have a Startingpoint 5. Wish me Luck no one will kill me for this Code if anyone wants to proof read the code or has any questions or suggested improvements, just reply.
    1 point
  36. I love code like this. Until sometime last year I wasn't aware you could be as clever as that, but now I'm doing things like this a lot with a system I'm updating where I don't want to edit hundreds of templates right now
    1 point
  37. It can work and is clean and simple. But it's not working if the user enters directly the image and not the gallery. Thank you slkwrm! url should href of course but thank you anyways it's working like a charm! EDIT: so echo "<a url='$url'>Back to galleries</a>"; should be echo "<a href='$url'>Back to galleries</a>";
    1 point
  38. There is a plugin for at least restrict the edits per user. Not sure if you can hide the rest, too: http://modules.processwire.com/modules/page-edit-per-role/ or https://processwire.com/talk/topic/2141-module-page-edit-per-user/ or http://modules.processwire.com/modules/custom-page-roles/ You probably have to read the description of them or try them and then decide which one fits our needs the best.
    1 point
  39. okay i found a way to more or less execute this. if i hook myself before ProcessPageList ___execute and overwrite id into the id the user should only see. public function ___execute() { $langID = (int) $this->wire('input')->get->lang; if($langID) $this->wire('user')->language = $this->languages->get($langID); //overwriting $_GET['id'] with the id i will put into his useraccount if(!$this->id) $this->id = isset($_GET['id']) ? (int) $_GET['id'] : 0; $this->openPage = $this->input->get->open ? $this->pages->get((int) $this->input->get->open) : new NullPage(); $this->page = $this->pages->get("id=" . ($this->id ? $this->id : 1) . ", status<" . Page::statusMax); if(!$this->page) throw new Wire404Exception("Unable to load page {$this->id}"); if(!$this->page->listable()) throw new WirePermissionException("You don't have access to list page {$this->page->url}"); $this->page->setOutputFormatting(false); // ensure that we use the page's title is always consistent in the admin (i.e. 'Pages' not 'Page List') $p = wire('page'); if($p->name == 'list' && $p->process == $this) $p->title = $p->parent->title; return $this->render(); } i would have the opportunity to get somewhat of an result what i want. what wont be solved is a szenario i do not have, but could happen. for example: susi should be able to edit not only: susi: content -> news -> security but also content -> history but now to something diffrent i will run into somewhat of an error. if i overwrite id to lock the user into a childpage i am not able to use "open" anymore. this is what i get when i use id on my "new" root and open for a child of this id: http://myadress.com/processwire/page/?id=1054&open=1055 someone halp ? :-\ P.s.: sorry if its hard to read
    1 point
  40. That pause solution works fine. About the font: I tested this on my Win 7, 17 inch laptop (1920x1080). For me it's looking pretty good on Chrome, although it's has less weight than how it is displayed in FF and IE. I threw together the schreenshots. I also noticed that in IE the menu bar is always grey. https://dl.dropboxusercontent.com/u/14376901/ed-works.png
    1 point
  41. Just as an idea - couldn't this field be called "published" just to match "created" ? Or is "published" a reserved word?
    1 point
  42. : https://processwire.com/talk/topic/1284-best-practice-for-staging-to-live-database-synchronization/ http://www.sitepoint.com/one-click-app-deployment-server-side-git-hooks/ https://github.com/netcarver/new-git-deployment https://processwire.com/talk/topic/5417-using-git-with-a-cms-for-version-control-and-deployment-on-multiple-machines/#entry53567 (I also use heidi-sql portable with great success)
    1 point
  43. Well there is this module by Adrian: Migrator You can export part or all of a sites page tree by selecting the parent and it has options to export everything, including all data pages, fields templates and structural pages or fields and templates only. You can also select a changes since date and time and you can select any additional files over the template files such as includes, css etc On the import side there are 3 options: APPEND will not change settings of existing fields, nor the content of existing pages. It will append new fields to templates and new pages (and date) to the selected Parent Page. OVERWRITE will change field settings and edit the content of existing pages so they match the imported data. REPLACE will match the destination to the source exactly, by modifying page data, changing field settings, and deleting unused fields from templates. You can import user data and created/modified dates as options. I have tried this with part of a page tree for a single page and it works ok. I haven't had time to test the changes since option, but maybe this module is close to what we need? When I have more time I will carry out some tests.
    1 point
  44. Very cool and right in time! - I was just about to hacking the original code to make it work in German. Your solution, using language translation files, is VERY SMART. - Works well so far (tested with PW dev, German/English). Thank you very much for this contribution!
    1 point
  45. ( ohne Worte - without words )
    1 point
  46. importnant say mom to step in nother mans shoes get purspectives so i make new avoters for you so u can shares purspectivos togther can u work for briter futurre brothers.you are now
    1 point
  47. have.more then 1 role a user may diffrent permissions a role.may have diffrent templates.a role.may be in much.have u learnt. ready u are
    1 point
  48. This should do what you're after: foreach($page->siblings() as $sibling){ echo "<li" . (($page == $sibling) ? " class='active'" : "") . "><a href='{$sibling->url}'>{$sibling->title}</a></li>"; } Written in the browser and not tested, but should be close.
    1 point
  49. Welcome to the forums abe.izar. Seems like they should make json_encode at least attempt to typecast an object to a string (which would convert to IDs here). Maybe I can update wireEncodeJSON (a front-end to json_encode) do that. However, if you really want to export pages and all their data to JSON, here's how you can do it: function pagesToJSON(PageArray $items) { $a = array(); foreach($items as $item) { $a[] = pageToArray($item); } return json_encode($a); } function pageToArray(Page $page) { $outputFormatting = $page->outputFormatting; $page->setOutputFormatting(false); $data = array( 'id' => $page->id, 'parent_id' => $page->parent_id, 'templates_id' => $page->templates_id, 'name' => $page->name, 'status' => $page->status, 'sort' => $page->sort, 'sortfield' => $page->sortfield, 'numChildren' => $page->numChildren, 'template' => $page->template->name, 'parent' => $page->parent->path, 'data' => array(), ); foreach($page->template->fieldgroup as $field) { if($field->type instanceof FieldtypeFieldsetOpen) continue; $value = $page->get($field->name); $data['data'][$field->name] = $field->type->sleepValue($page, $field, $value); } $page->setOutputFormatting($outputFormatting); return $data; }
    1 point
  50. Sneak Preview (everything configurable, styling mostly controlled by admin theme):
    1 point
×
×
  • Create New...