-
Posts
2,769 -
Joined
-
Last visited
-
Days Won
31
Everything posted by Martijn Geerts
-
@Sevarf2, would you mind to try the following ? Add a new method somewhere in the module: /** * Return Mimetype * */ protected function mimetype($filename) { if (function_exists('finfo_open')) { $info = finfo_open(FILEINFO_MIME_TYPE); $mime = finfo_file($info, $filename); finfo_close($info); } else if (function_exists('mime_content_type')) { $mime = mime_content_type($filename); } else { $mime = 'application/octet-stream'; } return $mime; } And then change the code for the mime type: /* Disable this: */ // $info = finfo_open(FILEINFO_MIME_TYPE); // $mime = finfo_file($info, $field->filename); // finfo_close($info); /* add this: */ $mime = $this->mimetype($field->filename);
-
What kind of environment you're running this?
-
Welkom Frank ! Thanks for the short introduction. Don't be scared to to make spelling failures, I make them every time. Google translate is a big friend of mine. What do you want to know ?
-
@LostKobrakai, I love that last solution
- 4 replies
-
- pagination
- paging
-
(and 1 more)
Tagged with:
-
The problem is likely rendering of whitespace. When there's a space, a line-break or a multiple of white-space characters between the tags and the HTML tags are displayed inline (display: inline / display: inline-block / ) , a +/- 4 pixel whitespace is rendered. You could, make your own markup leaving out those white white-space characters. If you removed all whitespace between <ul> and all <li> You could add text-align: center to the UL, and set the <li> to inline-block.
- 4 replies
-
- 1
-
- pagination
- paging
-
(and 1 more)
Tagged with:
-
Getting my head around the intermediate default profile
Martijn Geerts replied to Russell's topic in Getting Started
For me there's too much logic in the main template in the example ryan has given. (if statements) I prefer to build the variable Markup in the template. Not in the _main.php <!doctype html> <html lang=en> <head> <meta charset=utf-8> <title><?= $page->headline; ?></title> </head> <body> <header><?= $header; ?></header> <nav><?= $nav; ?></nav> <div id='content'> <?= $page->content; ?> <?= $page->sidebar; ?> </div> <footer><?= $footer; ?></footer> </body> </html> I almost always use this approach, except that I do not use the automatic prepend and append functions from ProcessWire. I use a include(./_init.inc) and a include(./_main.inc) in the template file. template file +---------------------+ |include(./init.php); | | | |$title = "<h1>...etc.| |$content = "<div>... | | | | | | | |include(./main.php); | <-- could be changed, maybe we want to include ./special-main.php +---------------------+ When I need a major change how the page should look like, I could decide to include an other 'view' page in the bottom. -
Getting my head around the intermediate default profile
Martijn Geerts replied to Russell's topic in Getting Started
The idea behind this concept is that _main.php would NOT contain any logic at all. The only thing that _main.php will do is echo out the variables & markup. Default variables are created in the _init, if needed, those variables can be overwritten in the template. +----------+ | _init | $title = "<h1>$page->title</h1>"; | | $content = "<div class='seventy-five_percent_wide'>$page->body</div>"; | | $sidebar = "<div class='twenty-five_percent_wide'>$page->sidebar</div>"; | | | | +----------+ | +----------+ | template | Contains Logic. | | | | $title = "<h2>$page->title</h2>"; | | $content = "<div class='fifty_percent_wide'>$page->body</div>"; | | $sidebar = "<div class='fifty_percent_percent_wide'>$page->sidebar</div>"; +----------+ | +----------+ | _main | This file only outputs Markup. There's no 'logic' here (read no if statements and stuff) | | And the variables ($title, $content & $sidebar) will will be echoed here. | | | | | | +----------+ In the code block, you can see that the variables $title, $content & $sidebar are first setup in _init. We see the following: The title is a <h1> header. The content is markup with a column of 75% wide The sidebar is markup with a column of 75% wide This are nice defaults as most of our pages are structured like this. When we want these defaults, the template file can be empty. But if we need a page with 2 columns equal wide and have a H2 header instead of the H1, we could overwrite the variables in the template file. As you could see in the code block, we overwrite $title, $content & $sidebar. The main file could simply look like this: <!doctype html> <html lang=en> <head> <meta charset=utf-8> <title><?= $page->headline; ?></title> </head> <body> <?= $page->title; ?> <?= $page->content; ?> <?= $page->sidebar; ?> </body> </html> -
@KentBrockman, it's all in the family.
-
Sorry, pages is the easiest way I guess. Say a stallion has 50 or more children, how to manage that not relational?
-
Blad you've done some fine piece of work . And agree here with both teppo & diogo.
-
Why no uppercase or special characters in the attached files
Martijn Geerts replied to lpa's topic in Wishlist & Roadmap
There are some flavors of Windows/DOS that are not case sensitive when it comes to comparing filenames. So some operationg systems consider "processwire.gif", "ProcessWire.gif", "PROCESSWIRE.GIF" and "PROCESSwire.gif" to be the same filename. If PW would allow the case sensitive differences in file names you could imagine this will have consequences. Imagine this: I upload a file called 'ProcessWire.gif' on wamp installation, then I upload on the same page 'PROCESSWIRE.GIF', now 'PROCESSWIRE.GIF' overwrites 'ProcessWire.gif'. Filenames in ProcessWire need to be used in URL's so the filenames should be compatible with the rfc3986 standaard. This leaves us with a restricted set of characters minus the uppercase characters. -
Not only today Charles Thanks adrian, will check it out soon.
-
Stuck with $pages->get("/path/to/page/") inside <a href=""></a>
Martijn Geerts replied to pwired's topic in API & Templates
Play Tarzan: echo "<div id='button3' class='button_style'><a href='{$pages->get('/kontakt/')->url}'>kontakt</a></div>"; -
I'm no git hero... I tend to mess it up for my repositories all the time. Tnx for the update.
-
Actually, you don't turn it on for the admin, but for the specific page getting rendered. Untill now I don't see any negative side effects.
-
Can't help you with your questions. ps, I would love to see the the iframed one, so +1 for the sandboxed.
-
Hi Joss, Do you have a mac ? If so, mail is disabled by default. I've re-written instructions to enable it
-
It looks like that OutputFormatting is off when you open a page with that contains a PageTableExtended field. After editing a 'page' and closing the modal, OutputFormatting kicks in and the page renders as expected. Is there a way to enable OutputFormatting right away? Oké, I should not complain When I add OutputFormatting to the page at line at line 52 it looks like it resolves the issue: //InputfieldPageTableExtended.module $parsedTemplate->page->of(true); (Made a pull request on github)
-
I'm not sure I fully understand what you're up-to, but using urlSegments to work with AJAX is in my opinion a good thing, because urlSegments are fully cache-able. You could on template level, output the data corresponding to the urlSegments. On a local project I do store all the json & markup results in a JSON object after the data has been pulled in, the next time the data is requested, the data is pulled from the JSON object so no extra request has to be made to the server. If used in combination with pagecache, it's real quick offtopic: I've used History.js and I love it.
-
Those CamelCase tables are CamelCase because the classname of the module I think. And all of them are not written by Ryan I believe. Probably they used $this->className() as table name what makes perfectly sense to me.
- 2 replies
-
- 1
-
- Database
- Naming Convention
-
(and 1 more)
Tagged with:
-
Thanks, fixed.
-
Little tutorial for adding a "truncate text" function to a text/textarea fields. Here's a little step by step tutorial how to add javascript behaviour to fields using Admin Custom Files. We are gonna truncate the text length of the title field. The plugin only works for simple text and textarea fields and is language aware. Note that the plugin won't work for TinyMCE or CKEditor a likes. Create a file in the Admin Custom Folder called: ProcessPageEdit.js Create a file in the Admin Custom Folder called: custom-plugins.js Go to custom-plugins.js and copy/paste the plug-in code and save the file. Open the ProcessPageEdit.js file and paste in the code from Using the plug-in and save the file. Go to the Admin Custom Files module settings Select the process ProcessPageEdit In the Dependencies textarea type: ProcessPageEdit AdminCustomFiles/custom-plugins.js Save the module. You're done, go to a page where you have a title field to see the result. plug-in code: /site/templates/AdminCustomFiles/custom-plugins.js (function ($) { $.fn.truncate = function(options) { var $fields = this, name = $fields.attr('name'), settings = $.extend({ characters: 128, prefix: '', suffix: '', class: 'notes' }, options ); if ($fields.parent('.LanguageSupport').length) { var $fields = $("#langTabs_Inputfield_" + name ).find("input, textarea"); } $fields.after("<span class='" + settings.class + "'></span>"); $fields.each(function (index, el) { var truncate = function () { var value = $(el).val(), typed = typeof value != 'undefined' ? value.length : 0, left = settings.characters - typed; if (left < 0) { $(el).val(value.substr(0, settings.characters)); truncate(); } else { $(el).next("span").text(settings.prefix + left + settings.suffix); } } $(el).keyup(function() { truncate(); }); return truncate(); }); }; }(jQuery)); using the plug-in: /site/templates/AdminCustomFiles/ProcessPageEdit.js // DOM is ready $(function () { // field with the name attribute title $("[name='title']").truncate({ characters: 64, prefix: 'To go: ', suffix: ' characters' }); });
-
Good advise Bwaked: I will also set my set my mind to 0, with a new beer.
-
Here's some reading about types bwaked: http://php.net/manual/en/language.types.php I hope that clarifies a bit. It will take some time to fully understand what is going on, but take your time, we all did.