Leaderboard
Popular Content
Showing content with the highest reputation on 03/25/2016 in all areas
-
For a little data visualization task at work, I (finally) got to do some tinkering with WebGL / 3D, and as a small Easter egg, I thought I'd share one of the (admittedly a bit crude) side results for anybody also new to and interested in 3D in the web. Before I went into full-blown meshes and textures, I animated DOM elements in 3D and built a little spinner to get a feel for positions, camera and the behaviour of my library of choice, three.js. Don't mind the "Sitemap 3D" title in the screencap, that was just a spur-of-the-moment thing, but what came out was a classic (static) spinner. I really love how you can move regular HTML elements through thee-dimensional space and still use all the regular CSS styling, including colors, transparency, borders and shadows. Step-by-step: Download three.js from GitHub and extract it into a folder named "three.js" in site/templates (it comes with all examples and is a bit big, but we need a few of those). Adapt the template you want to show your 3D spinner in to include jQuery, the three.js main file, CSS3DRenderer and Tween (the latter is used for smooth animations). <script src="<?= $config->urls->templates ?>three.js/build/three.js"></script> <script src="<?= $config->urls->templates ?>three.js/examples/js/renderers/CSS3DRenderer.js"></script> <script src="<?= $config->urls->templates ?>three.js/examples/js/libs/tween.min.js"></script> <?php $jq = $modules->get('JqueryCore'); foreach($config->scripts as $script) { ?> <script src="<?= $script ?>"></script> <?php } ?> Add a div with position: relative and a fixed height (fixed width is optional) in your template and give it an id (in my example I'll use "main"). Paste the following code into a php file in site/templates and include the file in your template before the closing body tag. If you gave your container an id different from "main", adapt the first parameter for the showSpinner call close to the bottom. <div id="spinnertmp"><!-- A temporary container --> <?php // Get our list of items. The first item in the PageArray is shown front center. $mainpages = $pages->find('parent=1')->and($pages->get('/'))->reverse(); $links = array(); $first = true; foreach($mainpages as $pg) { $id = "smitem_{$pg->id}"; $links[] = $id; $cls = ""; if($first) { $cls = " smactive"; $first = false; } // Our spinner items: echo " <div class='smitem$cls' id='$id'> <a href='#' class='smleft'><</a> <a class='smlink' href='$pg->httpUrl' title='$pg->title'>$pg->title</a> <a href='#' class='smright'>></a> </div> "; } ?> </div> <script> function showSpinner(el, prnt) { var camera, scene, renderer; var links = [ <?= implode(",\n\t\t", array_map(function($v) { return "'$v'"; }, $links)) ?> ]; var w, h, wInt, hInt; var objects = []; /** * On window resize, we also recalculate our camera position and set the * size of the render canvas. This last step may not be necessary if you * use a containing element with fixed bounds. */ $(window).on('resize', function(evt) { camera.position.z = w / 1.5 + 250; camera.updateProjectionMatrix(); renderer.setSize($(el).innerWidth(), $(el).innerHeight()); circle(); }); /** * Prev and next link click handlers for our spinner items */ $('.smleft').on('click', function(evt) { evt.preventDefault(); goLeft(); }); $('.smright').on('click', function(evt) { evt.preventDefault(); goRight(); }); // Get the show started, init() also calls render() init(); // Remove the no longer needed container for our spinner items from the DOM $(prnt).remove(); // Start the animation loop animate(); // Move our spinner items into a circle circle(); /** * Rotate the circle left/right by moving the first/last item * to the other end of the item stack and letting circle() * move them into the new positions. */ function goLeft() { objects.unshift(objects.pop()); links.unshift(links.pop()); circle(); } function goRight() { objects.push(objects.shift()); links.push(links.shift()); circle(); } /** * Initial setup */ function init() { $(el).css('padding: 0;'); w = $(el).innerWidth(); h = $(el).innerHeight(); wInt = ( w - 80 - 150 ) / links.length; hInt = ( h - 80 - 50 ) / links.length; camera = new THREE.PerspectiveCamera( 40, w / h, 1, 10000 ); camera.position.z = w / 1.5 + 250; scene = new THREE.Scene(); for(var i = 0, l = links.length; i < l; i++) { var $el = $('#' + links[i]); // create a CSS3DObject from each spinner item element var object = new THREE.CSS3DObject( $el.detach().get(0) ); var curpos = object.position; // for a start, let's align them all in a diagonal row object.position.x = -1 * w + 2 * (i * wInt + 40); object.position.y = -1 * h + 2 * (i * hInt + 40); object.position.z = 50 * i; objects.push( object ); $(el).append($('#' + links[i])); scene.add( object ); } renderer = new THREE.CSS3DRenderer(); renderer.setSize( w, h ); renderer.domElement.style.position = 'absolute'; $(el).append($(renderer.domElement)); render(); } /** * Arrange our items in a circle and float them to the target position */ function circle() { // Get our containing element's coordinate measures w = $(el).innerWidth(); h = $(el).innerHeight(); wInt = ( w - 80 - 150 ) / links.length; hInt = ( h - 80 - 50 ) / links.length; // Make the radius and placement angle dependant on the number of // items and the size of our canvas var l = objects.length; var radius = w / 1.5 - 200; var cX = 0; var cZ = 0; // just basic radians/degree conversion math, nothing to be afraid of var mpi = Math.PI / 180; var startRad = mpi; var incAngle = 360 / l; var incRad = incAngle * mpi; // Let's do some cleanup before the party starts again TWEEN.removeAll(); // Move every item to its new assigned position for(var i = 0; i < l; i++) { // x and z coordinates (left-right and back-front), no y needed as all stay at the same height var xp = cX + Math.sin(startRad) * radius; var zp = cZ + Math.cos(startRad) * radius; // our item's rotation as it revolves around the circle var rotY = i * incAngle * mpi; /** * A tween is a smooth transition over a given time. You pass the start values (must be numbers) * to the constructor and the desired destination values to the to() method. The property names * can in fact be arbitrary but need to be consistent between the constructor and to(). * * The onUpdate handler will be called every time a frame is ready, and the correct transition * values are set to corresponding properties of the "this" object. Assigning the passed properties * to a 3D object is the task of the developer. */ (function(mObj, twNum){ new TWEEN.Tween( {x: mObj.position.x, y: mObj.position.y, z: mObj.position.z, rotY: mObj.rotation.y } ) .to( {x: xp, y: 0, z: zp, rotY: rotY}, 1000 ) .onUpdate(function() { mObj.position.x = this.x; mObj.position.y = this.y; mObj.position.z = this.z; mObj.rotation.y = this.rotY; }) .onComplete(function() { // color only the item currently in the front (first item in our stack) differently $('.smitem').removeClass('smactive'); $('#' + links[0]).addClass('smactive'); }) .start(); // start the transition })(objects[i], i); // increment rotation for the next item startRad += incRad; } } /** * simple but magical, pushes itself onto the stack to be processed the next time * the computer is ready to draw the scene. */ function animate() { requestAnimationFrame(animate); TWEEN.update(); render(); } /** * paint it, dude! */ function render() { renderer.render(scene, camera); } } $(document).ready(function() { showSpinner('#main', '#spinnertmp'); }); </script> Style your container element and spinner items. Here's the CSS I used, but you can go all out there: #spinnertmp { display: none; } #main { height: 400px; position: relative; background-color: rgb(0,20,10); padding: 0; margin: 0; overflow: hidden; } .smitem { position: absolute; width: 200px; height: 50px; padding: 2%; border: 1px solid rgba(127,255,255,0.25); box-shadow: 0px 0px 12px rgba(0,255,255,0.5); text-align: center; left: 20px; top: 20px; background-color: rgba(0,127,127,0.40); display: flex; } .smlink, .smleft, .smright { text-decoration: none; font-size: 1.4em; font-weight: bold; color: rgba(127,255,255,0.75); display: inline-block; } .smlink { flex: 5; } .smlink:hover { color: rgba(255,215,0,0.75); } .smleft, .smright { flex: 1; } .smleft:hover, .smright:hover { color: rgba(255,127,127,0.75); } .smactive { background-color: rgba(0,0,127,0.60); } Load your page and enjoy!10 points
-
Our old website was built on WordPress site some 5 years ago. It was dated in design and was getting very difficult to manage. We had to change. ProcessWire has been our default CMS for 2 years now so it had to be Pigtail Pundits on PW. The theme was custom built on Foundation 5. Were we asking too much of ourselves? With projects and other work interrupting this dream? It took some time to cook - a year in the making. Plus, some distractions like the logo change after we started the design. The copy was re-written twice. Finally, we dropped everything else and put all our energies to make it live in January this year. And quietly worked on parts that still needed working since. It’s now ready to be seen: https://www.pigtailpundits.com The Functionality PageTable Extended with ProFields for page layouts that break the rhythm ProCache for fast caching Sendy for Newsletters Download Guard for PDF downloads FormBuilder for forms Animate.css for on-page effects Custom coding for email a friend and Print this. SVG images for logo, branding Let the opinions flow in.10 points
-
Hi all, Just in front of the Easterweekend, my first contribution to the modules section of ProcessWire. I created a module to send Tweets when selected at the page editor. From version 0.8.3 up the module is only to use in v3.x. When using ProcessWire v2.x you should use version 0.8.2. In short this module offers an option to publish a page to Twitter when the date for publishing is past/scheduled. After filling out the Twitter credentials, select your preferable template(s) which should have the option added to Tweet the pages using it. Additional select the field to use as publicationdate to check if the Tweet should be send now or later, a field which contains the page title. Optional you can fill out the name of the website which will be added after the title (in case space is available). Optional you can select the field where the page image(s) are placed (only one will be tweeted). Optional you can fill out Bit.ly credentials for shortening URLs. Includes instructions to set a cron (template or LazyCron), returns log in assets folder. Uses (included) TwitterOAuth PHP library written by abraham. http://modules.processwire.com/modules/publish-to-twitter/ https://github.com/FerdiAgrio/PublishToTwitter Enjoy!9 points
-
In this week's blog post, Adrian Jones introduces his new Tracy Debugger module for ProcessWire. Enjoy this in-depth overview and tutorial where you'll learn a lot of new and useful things. An epic post on one of the most useful modules for PW! https://processwire.com/blog/posts/introducing-tracy-debugger/6 points
-
The latest PW blog post is all about TracyDebugger: https://processwire.com/blog/posts/introducing-tracy-debugger/ Hope you guys find some new info and tips in there - sorry, it's a pretty long read4 points
-
As an alternate solution, you can create a Settings page just for the purpose to store global vars. Especially useful if you deal with multiple languages. I usually add a multilang text area and apply multivalue textformatter (see my sig). Set its access to admin only to avoid others modifying it. In most cases addig it to the Home page is enough.4 points
-
3 points
-
3 points
-
By the way I believe MySQL 5.7 has a JSON format that can be queried, probably wouldn't be too hard to build a field type around it.3 points
-
As those don't need custom content you probably can go for urlSegments instead of real pages.3 points
-
I just added another option to this module that can limit the automatic naming to match the title to only unpublished pages. If the page is published, the name will be left untouched. This might help out those users who are steadfast in their opinion that the URL to a page should never change - not judging this opinion by the way - it is a very strong argument. With this new setting you can change the title multiple times while it's still in unpublished (in draft if you will) and the name will change automatically. Once it is published, changes to the title won't affect the name. Hope that wins a few more users over2 points
-
I should have thought that you are also working while traveling Thanks again for one of the most useful modules and for the blog post as well!2 points
-
2 points
-
Oh no problem with delays - we have no contract it's all sparetime and fun and times are not always funny... My condolence for you and your family. Yes your are right the module development is a little lack of examples but some of the existing modules (from ryan and others) give very good insights on most of the things...For me i'm not a developper but i was able to create 2-3 little modules and/or adapt others... May we could team up on this if you have some further time and motivation later this year. Don't hesitate to write me a PM on this topic - nevertheless i like your concept of pagebased comments and would be proud to help even if i not the real PW dev you may wish/need to team up Best regards and wishes mr-fan2 points
-
Thanks szabesz, I think I should have more understanding of bernhard's usecase. Fortunately PW is flexible enough to handle such scenarios.2 points
-
When the administrator should be able to change settings, your solution works fine, however, adding our own standard classes to HTML elements is a different problem I think. bernhard wants to create a collection of HTML classes which can be easily applied to an element, and normally we do not want the administrator to change these values. Building these collections the beginning of the template file is good idea.2 points
-
@Nukro, How about using kongondo's wonder-field module (instead of a summary field) and have it access the value you want?2 points
-
@Martin, Will do. As soon as I get it worked into the demo for my client. This morning I gave the module quick-add power! No more manipulated step1 form, goes straight to the full page editor.2 points
-
Hi @Tom Walcher and welcome to the forums. It is for getting variations of an image - cropped, resized, etc. So based on a quick look, you probably won't see these variations listed in your images field. Not ideal, but maybe not critical for you needs - hard to say. The getExtension method for DirectoryIterator was added in PHP 5.3.6 so that is your key issue. There are other places it is used in the PW core though too: https://github.com/ryancramerdesign/ProcessWire/search?utf8=%E2%9C%93&q=%22-%3EgetExtension%22 So you might have other issues when viewing log files through Setup > Logs or dealing with multi-language stuff. It actually wouldn't be hard at all to replace this method with another approach to getting the file extension, but given that PHP 5.3.3 is 6 years old I think you might be better off hassling your hosting provider to update their system2 points
-
got it! as simple as that: function addClass($element, $class) { $pw = wire(); // current pw instance $classes = wire('classes'); $classes[$element][] = $class; $pw->wire('classes', $classes); } in the other files: // _init.php // set classes for parent container addClass('tm-main', 'tm-section'); // blog.php addClass('tm-main', 'tm-blog'); // _main.php <section id="tm-main" class="<?= getClasses('tm-main') ?>"> <?= $content ?> </section> see apigen docs: http://kongondo.github.io/ProcessWireAPIGen/devns/source-class-ProcessWire.Wire.html#1027-1037 thank you szabez! also thank you horst for jumping in2 points
-
Use the dev tools, padawan ! A slideshow with a button on top of the page with position fixed and z-index + some javascript to make it go away. Edit: it is not even on top - the enter button is a link. A padawan answer)2 points
-
For all followers: A single line (250) needs to be changed to work with PW 3+. $include_fuel ? wire('all')->getArray() : array(), ( see this post: https://processwire.com/talk/topic/12298-update-273-to-308-processwiregetarray-does-not-exist/#entry114410 )2 points
-
Yes, animation are too much, otherwise there are many interesting design/UI solutions. Thanks for the insight!2 points
-
@szabesz, those kinda things happen 'all the time'.2 points
-
Go get a coffee This works too: // _init.php (mind the underscore) wire('testArr', array()); $testArr['initValue'] = 'helloworld'; // home.php (no underscores at all) $testArr['myArr'] = array( 'first' => 'veryfirst', 'two' => 'veryfirst' ); // create variables from $testArr array extract($testArr); echo '<pre>'; var_dump($initValue); echo '</pre>'; echo '<pre>'; var_dump($myArr); echo '</pre>';2 points
-
Many ProcessWire 2 modules will work in ProcessWire 3, thanks to the compiler. So, you code as 'normal' If you want a PW3-only module, just add namespace ProcessWire at the top of the module class There's some stuff that will only be supported in ProcessWire 3. If you want to leverage those and don't care about PW2, then go for 3 directly. Otherwise, if you have the resources and can support both, then go for two separate PW2 and PW3 modules. PW2 will still be around for a while .....but to PW3 we'll 'all'(?) go..eventually...so.. https://processwire.com/blog/posts/processwire-3.0-alpha-2-and-2.6.22-rc1/2 points
-
Here are some of my findings in case anyone need it: // hook to before page add render and prevent execution if necessary $this->addHookBefore('ProcessPageAdd::execute', $this, 'hookUserAdd'); // hide add button in the backend menu $this->addHookAfter('ProcessUser::executeNavJSON', $this, 'hideUserMenu'); public function hideUserMenu($event) { //we don't want to modify links for super user if ($this->user->isSuperuser()) return; //ajax only if($this->config->ajax){ $options = json_decode($event->return, true); unset($options['add']); foreach ($options['list'] as $key => $value) { //check and unset if necessary } $event->return = json_encode($options); } } public function hookUserAdd($event) { if (!$this->user->isSuperuser()) { $event->replace = true; $this->error('You do not have permission'); return; } } That is because I still want "staff" role to use page-lister permission. Hooking to ProcessPageLister is much harder and require regex to hide the "Add new" buttons. Also, to modify the result returned from the selector, you can add hook to getSelector function (this is undocumented in Captain Hook) $this->addHookAfter('ProcessPageLister::getSelector', $this, 'hookPageListerSelector'); For better security, add hook to Pages::save (similar to ProcessPageAdd) to deny saving new user.2 points
-
Hi, first of all I'd like to thank you all, and in particular Ryan, for this great project which is ProcessWire. I'm using ProcessWire for the first time and frankly I'm finding it quite good, despite my lack of experience. Anyway, I created this post to introduce you the following module, on which we are working, and I'd like to share it with the community which could benefit from it and maybe improve it. You can find the module here: https://bitbucket.org/mauro_mascia/processwire-social-login/ Basically, it adds the ability to allow a social login (using the HybridAuth library - https://github.com/hybridauth/hybridauth) as well as a standard login, user profile and registration. The module is clearly not complete and it is at its first stage of maturity and I hope you can forgive me if I have not fully complied with the PW best practices1 point
-
This is a description of a 'members' setup, where a 'member' is a processwire user who is able to manage their own branch of the page tree. Based on a simple site that looks a bit like this. HomeMembersMember APage A1 Page A2 Member B Member CPage C1 Etc. Section XPage X1 Page X2 Section YPage Y1 Members A, B and C can add, edit, sort and delete children of their page Member A/B/C. They may also edit their page Member A/B/C. Without any additional roles they have just ‘view pages’ access elsewhere. Take Section X above as an example, and two roles ‘editor’ and ‘sub-editor’ where the role ‘editor’ can add/edit/delete pages beneath Section X; and the role ‘sub-editor’ can edit pages beneath Section X. Assigning either of these roles to a user who also has the ‘member’ role does not interfere with either scheme. Setup Before adding users I do the following: Enable the permission ‘page-edit-created’ Create a role ‘member’ and grant it ‘page-edit’, ‘page-delete’, ‘page-edit-created’, and ‘page-sort’ permissions Create a template ‘member’ and enable access controls granting role ‘member’ ‘edit pages’ and ‘add children’ in addition to the default ‘view pages’Use the ‘Revoke permissions by role’ function to remove ‘page-delete’ for the role ‘member’ Enable the advanced option ‘Allow the ‘created user’ to be changed on pages’ Create a template ‘members’ and under family settings allow children (specify the ‘member’ template as the allowed template for children/‘members’ template as the allowed parent for template ‘member’); optionally allow only one page using the template ‘members’ Create (or reuse) templates for the children of template ‘member’; specify these as the allowed templates for children of template ‘member’; grant ‘edit pages’ and ‘create pages’ to the role ‘member’ on these templates. Insert the following between lines 638 and 640 in file wire/modules/PagePermissions.module } else if($page->template->name == 'member') { if($user->id == $page->created_users_id) { $addable = true; } Add/Edit a user (e.g. ‘Member A’) and assign role ‘member’ Create a page (e.g. ‘Members’) in the tree with template ‘members’ Add a child page (e.g. ‘Member A’) to the page ‘Members’ On the page ‘Member A’ under Settings, change the ‘Created by User’ to the user ‘Member A’ Repeat for all users assigned the role ‘member’. Er, that’s it. It seems obvious to me that this could be made into a module. I haven't the experience, skills, knowledge required to complete that quickly, but the above works nicely in the way I want it to and this may be of benefit to others here. There may be unintended behaviour that I haven’t located yet. For example (though this is possibly not related to this setup) I’ve seen that when a textarea field has CKeditor as the inputype the ‘member’ users are able to insert images from any page, which is not the desired behaviour. I’ve seen some forum posts that address this, or similar such that I’m confident that this could be overcome. If it were a module, I think this defines what the module does. On install/configure Ask for a plural and singular version of your membership. Check for and enable if necessary the permission ‘page-edit-created’ Check for and create a role ‘singluar’ and enable permissions ‘page-edit’, ‘page-delete’, ‘page-edit-created’, and ‘page-sort’ Check for and create a template ‘plural’ Check for and create a template ‘singular’ and assign ‘edit-pages’ and ‘add pages’ to role ‘singular’‘singular’ template, Allow the ‘created user’ to be changed for pages using this template. Modify the Family rules for the two templates:‘plural’: Can this template be used for new pages?: One (no more allowed) ‘plural’: Allowed template(s) for children: ‘singular’ ‘singular’: Allowed template(s) for parents: ‘plural’ Modify the file wire/modules/PagePermissions.module as per the above In action When a user is assigned the role ‘singular’, (e.g. user ‘Nic’) the following actions are executed. Check for and add a page ‘Nic’ with template ‘singular’ under parent ‘plural’ Change the created user ID for page ‘Nic’ to that of user ‘Nic’. Other ideas Ask at install time where the root page ‘plural’ should be created and create it. What to do when removing the module. Tackle the CKeditor insert image issue EDIT/ADDITION: Either a change to the user template to include a "Full Name" for creating member pages (title field); or less intrusively, add a "Full Name" field to the "member" template and allow the member to enter their own.1 point
-
Hi @slave - sorry you haven't had a reply until now. I haven't tried that combination myself, so not sure if it will work or not, but the new Repeater Matrix field sounds like it might suit your needs: https://processwire.com/api/modules/profields/repeater-matrix/1 point
-
URL segements are great you could create a own little routing with the different segements to your scripts (login, logout, register...) But if you go the template way with a Adminbranch for example /app/ and subpages like /app/login/ you could take a look at this module from adrian: https://processwire.com/talk/topic/11499-admin-restrict-branch/ regards mr-fan1 point
-
Adrian, Many thanks for this debugger. It. Is. Fantastic! Could I request the xdebug integration, please.1 point
-
hi benbyf, the images are tremendously huge!! the first for example is 2248x3000 @ 1.9MB it's so easy to fix this with PW: <img src="<?= $page->your_image->size(1000, 1000, array('cropping' => false))->url ?>" alt="..."> and it will keep its aspect ratio. keep in mind that on first load it will need lots of memory + cpu so there may be some timeouts, but when all the images are resized the following pageloads will be faster1 point
-
Hah! That's very cool. Though I must say I don't like waiting for stuff to play out. If that was the actual navigation I'd just go away. Better for some kind of slideshow I think. Thanks for the example. Maybe we should have a contest and see what people do with it.1 point
-
Try $this->configData['already_commented'] Just do a var_dump($this) for example and check what's available. Even better using Tracy Debugger.1 point
-
I am not sure what you are after, so a quick answer: In PHP, you cannot refer to a static method using $this. you need self::staticMethodName() Example of accessing module values (including getModuleConfigInputfields()) that are in a static method (ProcessBlog) Edit: Also, I don't see where $data is coming from in your code, line #731 point
-
1 point
-
Aah, I see. If you need to use the template file of the child pages, have a look at this long thread. @jonathan's post may be of special interest in your case. You do not need to use the redirect module for such a simple redirect. For such you use $session->redirect('url') like I indicated . Have a read here about the session variable.1 point
-
Hi DanJuan, I think your description is far too vague for you to get much help at the moment. You are more likely to get meaningful help if you provide a detailed description of the approach you are taking / code you've tried etc. Also, what do you know about HTML/CSS/JS?1 point
-
...and you tell him, that you will do the backend with processwire, what comes out is this: http://kreativan.net/blog/news/website-relaunch/1 point
-
If you haven't, you can read a bit in the docs here: https://processwire.com/api/modules/ Depending on what your module / class has extended, you may also use $this->pages->find() And if you use procedural functions, you can use function myFunction() { $pages = wire('pages'); $pages->find(); ...1 point
-
If you're using the api in classes or functions these variables are not available as such. You'd need to use $this->wire('pages') or wire('pages') depending on the current scope.1 point
-
That's the sanitizer (filename) at work. From PW's point of view, it doesn't matter. It will get the correct file (it has been renamed). So the question really should be, does it matter on your side? E.g. Do you have another API outside PW or another APP that will expect your image files named using a particular format? If the answer is no, then it doesn't matter. If yes, I think Adrian has a file renamer module that can be configured to your heart's desire.1 point
-
I haven't tested the new matrix field for now. PTE renders the selected templates/blocks for the editor. So the dev could create a simple visual blockeditor with drag and drop the blocks and prerender them like it looks on frontend or in a other way that fits in the backend like teammembers, slideimages and so on. Some things to mention: - Care for the used templates to render in SEO things - access the single parts are possible if you don't handle this (for example you have all PTE elements under a hidden parent the elements are accessable on frontend, too) - The CSS for prerendering is sometimes a little tricky since it could be that it crashes with the admin styles (only some special classes and maybe fontsizes and so on) you could use .renderedLayout Class on such elements in your special CSS file for PTE. I'm running PTE for pretty much every repeating element that is more complex like contentblocks, sliderimages with text and settings, teammembers, grouping documents and so on...all things that elements in summary are under a rage from 10 to maximum 40. If i need more elements like events or something i'll stick to pages. best regards mr-fan1 point
-
You would have to do it either manually or using the API. If it's only a few pages to deal with you could do it manually. Otherwise, use the API. Something like this. First, rename your current text field 'views_count' to something like 'views_count_old' Create an integer field called 'views_count'. Add it to your template (the one with pages requiring view counts) Backup your db Run the code below in a template file (doesn't matter which one) on a test install first if you can. If all goes well, run on your 'real' install If all went well, remove 'views_count_old' from the above template @note: Written in browser and haven't tested but it should work. If you have thousands of pages you will want to do it in batches foreach ($pages->find('template=template-with-views-count-field') as $p) { $p->of(false); $p->views_count = (int) $p->views_count_old; $p->save('views_count'); }1 point
-
include("/home/shutterblue/public_html/content/index.php"); $wire->pages->setOutputFormatting( true ); // u cansadd.this when boot trap $homepage = $wire->pages->get(1);1 point
-
@ESRCH That login code will throw error if you login 3 times with wrong credentials... I already tried to put a note in those various (dozens already and lost track of) threads that use this "exact" frontend login code, which works but has one flaw. Problem is that once the login throttle kicks in you're left with a exception error. It's not obvious and I think posting that code in the forum over and over just creates problems in the long run for everyone copy paste such code. Funny thing is that the code originally is from Ryan himself. Either Ryan should change the behaviour of the throttle code or you need to use this code instead with a try catch to catch the login throttle error: if ($user->isLoggedin()) { $session->redirect($pages->get('/')->url); } if ($input->post->user && $input->post->pass) { $username = $sanitizer->username($input->post->user); $password = $input->post->pass; try{ $u = $session->login($username, $password); if ($u) { if ($redirectUrl = $session->get('redirect')){ $session->remove('redirect'); $session->redirect($redirectUrl); } else { $session->redirect($pages->get('/')->url); } } else { $error = "Wrong username or password. Login failed."; } } catch(Exception $e){ $error = $e->getMessage(); } }1 point
-
Thanks Martijn I finally have it working with the following steps for all those interested. Create a file eg custom_styles.php outside of the templates folder <?php header("Content-type: text/css"); ?> <?php include("file://localhost/Applications/MAMP/mamp_sites/pw_template/index.php"); ?> <?php $link_color = $wire->pages->get("template=settings")->link_color; ?> .test_header { color: #<?php echo $link_color; ?>; } Make sure to use $wire rather than $pages1 point
-
Or just <link rel="stylesheet" media="all" href="<?php include($config->urls->root . "styles/style.php")?>" type="text/css" /> Edit: Sorry, again... not include but: <link rel="stylesheet" type="text/css" href="<?php echo $config->urls->root?>styles/styles.php" /> Put styles in the root /styles/styles.php And there you could do : <?php header("Content-type: text/css"); $bgcolor = '#000'; ?> body{ background-color: <?=bgcolor?>; } Or yeah the <style> tag could also be handy and an easy way to do this.1 point