-
Posts
2,769 -
Joined
-
Last visited
-
Days Won
31
Everything posted by Martijn Geerts
-
How can I double like your POST Adrian ?
-
You got it... You could think that it's a row in the database but that's not the case. (Dive in MySQL to find out) Every field is stored separately with the ID of the page. So ProcessWire makes joins (indexed) to give you all the data back what you're asking ProcessWire. So Loading a page and calling the title will only load the title, leaving the other fields alone... ..... silly me... Welcome Nanook !
-
Welcome to ProcessWire cssabc123, You interact with data in ProcessWire via the fields from a page. A page in ProcessWire has custom fields (where the data is). Every Page in ProcessWire is build from a template, that template tells the Page which fields the page has. In fact a template is a 'template' for a Page, you could call it a Page factory. Every template can have a template file. (the files in /site/templates/). When a Page has a template with a template file the page can be shown in the browser. When a Page is build from a template that has no template file, the Page can only be used as data container. But how do I get the data from an other Page you might think. That is where the $pages variable comes in. Go ahead and check out the docs.
-
Where did you find about ProcessWire?
Martijn Geerts replied to apeisa's topic in News & Announcements
Have a great time Hanna, welcome. -
$this->addHookAfter('Pages::saved', $this, 'saved'); After was missing in your example. That syntax is normally used for adding a new method to the class when that method don't exist. public function init() { $this->addHook('Page::trololo', $this, 'trololo'); } public function tralala($event) { $page = $event->object; // trololo $event->return = "https://www.youtube.com/watch?v=2Z4m4lnjxkY"; } // echo $page->trololo();
-
Changing the way save() function reloads the page ?
Martijn Geerts replied to antpre's topic in Getting Started
The save won't reload your page, it is the POST who 'reloads'. Big side note: When I read your post well it 'sounds' very dangerous what you are doing right now. (not that is has to be) Would you mind to post your code so we can get a better understanding... -
You can build logic upon a permission. if ($user->hasPermission('just-a-permission')) { // do something } Every user has role. (A Role extend Page, so behaves like a page)Every role can have multiple permissions (A Permission extends Page, so behaves like a page) Every user can have multiple roles. When you ask $user->hasPermission('something'), ProcessWire will loop all roles and see if one of those roles has that permission. And it returns a boolean true or false on it's findings.
-
serve different /site/templates/ based on domain?
Martijn Geerts replied to darrenc's topic in API & Templates
Place the below in your /site/config.php // Honour goes to Raymond Geerts for the idea ! $config->templates = array( 'dev.foobar.com' => 'devtemplate', // domain => templates folder name ); if (isset($_SERVER['HTTP_HOST']) && isset($config->templates[$_SERVER['HTTP_HOST']], $config->templates)) { foreach ($config->templates as $host => $folder) { if ($_SERVER['HTTP_HOST'] === $host) { // set new paths $config->urls->templates = "/site/" . $folder . "/"; $config->paths->templates = dirname(__DIR__) . $config->urls->templates; break; } } } -
serve different /site/templates/ based on domain?
Martijn Geerts replied to darrenc's topic in API & Templates
yes it can -
What.... NO COFFEE !!!
-
FieldtypeSelectFile & InputfieldSelectFile
Martijn Geerts replied to Martijn Geerts's topic in Module/Plugin Development
Could you change the line in the sanitizeValue method in The fieldtype to: $file = $this->config->paths->templates . trim(trim($field->folderPath, '/')) . '/' . $value; Then the first 'issue' should be fixed. (although it was mentioned in the notes below the setting) For the second issue, I have no time to invest now... will look at it this weekend. (Could be related to the first.) -
@regesh: Repeater items are pages
-
Remove duplicates in a foreach loop (but count them)
Martijn Geerts replied to Reid Bramblett's topic in Getting Started
You need an extra ) before the continue. If you count 3 ('s there should also be 3 )'s -
Rendering page manually without losing context?
Martijn Geerts replied to abdus's topic in API & Templates
I sometimes use the code below (include doesn't loose context). <?php // Allow to cache to a variable function getPartial($path_to_file) { ob_start(); include($path_to_file); return ob_get_clean(); } $partial = getPartial($config->urls->templates . 'partials/myfile.php'); -
Getting first image of an image field in ajax php file
Martijn Geerts replied to Henrik's topic in General Support
/** * It's not the used template, it is 1 page with the template my_template * You need to know that Page is the connection to your field value. */ $usedTemplate = $wire->pages->get('template=my_template'); /** * You get the images field from the Fields variable. The Field you have now is the Field * what is the 'bloilerplate' of the image field. The Field Object is not the place from * where the you want the data from. It's is there to use for Modules and lower level stuff. * Most likely, you will not often need the use of field Objects. * * Data in ProcessWire comes from the Page connection. See Page as the glue and * the pointer to the field value. */ $imageField = $usedTemplate->fields->get('images'); /** * There's no first() method in the context you provide here. As we discussed above you * You have a reference to a PageImage object. You see in the Exception that there is no * first() method */ $firstImage = $imageField->first(); There's good documentation written about the Page variable, that will give you insight in how you can get your data. Next there's good documentation about images. I would suggest the read the docs carefully, it's all well written and a joy to read. -
Added Macrura's Autocomplete Tags in Image Field to the drop-ins. Thanks Macrura !
-
I saw it was trending on GitHub yesterday.... Nice font !
-
@antpre, I don't think this is a problem with Fredi, but rather the core preventing the user to be modified.
-
it's ->getRandom() with an a no e
-
Would be cool to make it a Drop in.
-
The simplest solution I see: Create a template file content_block.php Create a folder in your /site/templates/ folder called content-blocks Put in all content blocks you want (can be just .text or .PHP, whatever you wish) Download and install: FieldtypeSelectFile, give it a name. Go to templates add new template with the field you just created, name it content_block. Set the setting of the field to the folder content-blocks Check the Change Page Template setting. Create for every content block a page with the content_block template. Select in every page the block you want to render. Then the magic: // name of the content block template. $blocks = $pages->find("template=content_block"); foreach ($blocks as $block) { echo $block->render(); } Or you can make a pagefield (multiple) allowing al pages with template content_block.
-
It's in that module, the URL of the image is abstracted and from there pointed back to the page image. There are a few pitfalls: The image doesn't have to be uploaded on the current Page. (You need to go back to the page from the URL) The image can be single or array. (Could be solved by setting OutputFormatting to false on the page where you get the image from and set it back afterwards ) Other possible pitfalls: cropped images, didn't test it then because those options were not there.