Leaderboard
Popular Content
Showing content with the highest reputation on 09/16/2012 in all areas
-
I'm gonna release this in couple of days, still isn't finished, polishing up the details. Here is a sneak preview...3 points
-
Share your experiments. I thought I'd share something I've done a little while ago experimenting and trying out things you can do with js and SVG. So vector graphics for the web even older browsers can (IE had VML). 1. One is the famous Chromachron watch, I've created an accurate browser version (with a little twist in the center, which is not on the real clock). Done using the amazing javascript SVG library RaphaëlJS. http://soma.urlich.ch/chromachron/ 2. A fun experiment with RaphaëlJS for drawing and toxiclibjs (from java), a great physics library for the physics. You can click to fix the tail of the spring. (better have a fast browser) http://soma.urlich.ch/toxictale/ Have fun.2 points
-
2 points
-
Hey ho, I wrote a new module: ProcessShortcodes. It brings Wordpress like shortcodes to Processwire. A quick example: <?php $shortcode = $modules->get('MarkupShortcodes'); $shortcode->add('login', function($atts){ return '<form><h3>'.$atts['content'].'</h3><label>Enter password for "'.$atts['name'].'":</label> <input type="pass"></form>'; }); $content = 'Lorem ipsum dolor [login name="user"]Login[/login]'; echo $shortcode->render($content); ?> You can: add a shortcode: $shortcode->add('login', function($atts){ return '<form><h3>'.$atts['content'].'</h3><label>Enter password for "'.$atts['name'].'":</label> <input type="pass"></form>'; }); remove a shortcode: $shortcode->remove('login'); remove all shortcodes: $shortcode->remove_all(); and use them: $shortcode->render('Lorem [ipsum /] hello. [dolor name="nico" /]. Third possibility: [abc def="hij"]a text[/abc]. '); As seen above there are three different possible syntaxes: 1.: [shortcode] or [shortcode /] 2.: [shortcode key="value" /] or [shortcode key="value"] or [shortcode key="value" second="bla" /] 3.: [shortcode]lorem ipsum[/shortcode] or [shortcode key="value"]lorem ipsum[/shortcode] or [shortcode key="value" second="bla"]lorem ipsum[/shortcode] You can download it here: https://github.com/NicoKnoll/MarkupShortcodes I will add it to the module section as soon as possible.1 point
-
Definitely -- anytime you need something to be hookable just edit it, precede the function with the 3 underscores (to make sure it does what you want) and then let me know and I'll update the source to have it hookable. This is possible in most cases. Occasionally, there will be function that is used so much that making it hookable would be an overhead concern, but there's very few of those.1 point
-
These are really awesome Soma! I also think it's priceless that the Swiss guy here is making watches… in javascript.1 point
-
One thing I noticed is that it can take quite some time to load the statistics and I think there should be some ajax loader indicator animation while it's loading.1 point
-
I did that. Result is: a) when in Chinese page, LangName:hans b) when in English page, LangName:[empty] Any idea? Thank you Soma for spending the time to find out this tricky problem and solving it for me. I am also appreciate everyone of you for spending time reading and answering to my questions.1 point
-
This I like more: http://www.photoswipe.com/ Ok not really lightbox, but nice gallery for different devices.1 point
-
Ryan, Thank you for your help! It ended up being something different. I changed my form tag to the following at it works now. hooray! <form action="" method="POST" enctype=multipart/form-data> I didn't originally have the enctype=multipart/form-data in there. I don't know what I was thinking.1 point
-
One of the ways is to extend user template (don't forget to set filter to display system fields in the list) with a new field "viewable_pages" of a Page type and let site admins select pages that user need view. In order it to work you have to add additional check if the current page is accessible to a user into all of your templates (you can do it in the header you include in each template). Then if the page is in the list you output it's content to a user otherwise you redirect them or show them an error message. Should be something like this: if ($user->viewable_pages->has($page)) showUserContent(); else showError(); This is one of the basic methods, there are many of them, as always in PW1 point
-
1 point
-
Ok, many thanks for the advice I want to benefit from caching & indexing, so I'll stick to url segments, and some encoding mecanism.1 point
-
Just stumbled upon Fresco. It features a responsive (even my mother is responsive these days) lightbox, fullscreen zoom, retina-ready skins (sweet), Youtube and Vimeo integration for HTML5 video and a powerful Javascript API (seems cool). Haven't used it, but looks really nice.1 point
-
Use google to search processwire.com "site:processwire.com keyword"1 point
-
This should do it (cleaned from other module, so not sure if this works without fixing, but idea should be pretty clear): <?php class Elections extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Elections', 'version' => 101, 'summary' => 'Simple module to demonstrate how to automatically create subpages.', 'singular' => true, 'autoload' => true, ); } public function init() { // add a hook after the $pages->save $this->pages->addHookAfter('save', $this, 'afterPageSave'); } public function afterPageSave($event) { $page = $event->arguments[0]; // We want to create subpage only when using if ($page->template == 'election' && $page->numChildren == 0) { $p = new Page(); $p->template = $this->templates->get("candidates"); $p->parent = $page; $p->title = "Candidates"; $p->sortfield = wire('fields')->get('v_candidate_number'); $p->save(); $p2 = new Page(); $p2->template = $this->templates->get("votes"); $p2->parent = $page; $p2->title = "Votes"; $p2->save(); $this->message("New election created."); } } }1 point
-
Ryan, Thanks this gave me a great place to start. I thought I'd share the version I created in case anyone finds it useful. • Single template for the login/logout. • Automatically redirects the user back to whatever page they originally requested after they login. ./includes/login.php <?php // Handle logouts if($input->get->logout == 1) { $session->logout(); $session->redirect($page->path); } // If they aren't logged in, then show the login form if(!$user->isLoggedin()){ // check for login before outputting markup if($input->post->user && $input->post->pass) { $user = $sanitizer->username($input->post->user); $pass = $input->post->pass; if($session->login($user, $pass)) { // login successful $session->redirect($page->path); } else { $session->login_error = 'Login Failed. Please try again, or use the forgot password link below.'; } } ?> <!DOCTYPE HTML> <html lang="en"> <head> <title>Custom PW Login</title> </head> <body> <form action='./' method='post'> <div class="login"> <? if($input->post->user && $input->post->pass) { echo "<p class='error'>" . $session->login_error . "</p>"; }?> <p><input type='text' id="user" name='user' placeholder='Username'/></p> <p><input type='password' id="pass" name='pass' placeholder="Password" /></p> <p><input type='submit' class="btn" name='submit' value='Login' /></p> </div> </form> </body> </html> <? die(); // don't go any further if not logged in } // end !logged in ?> In any template you wish to protect: <? require("./includes/login.php");?> To trigger a logout: <a href="?logout=1">Logout</a> Note: I'm using the HTML5 placeholder attribute. Browser support is not 100%. You may want to use labels instead, or use some jQuery (like I did) to add the placeholder text for browser that don't support it. SideNote: How do you get code indents to stick when posting? I'm having to go back and add spaces to each line. I use tabs when coding.1 point