-
Posts
344 -
Joined
-
Last visited
-
Days Won
1
Everything posted by fbg13
-
Fieldtype/inputfield for uploading to aws s3 module
fbg13 replied to fbg13's topic in Module/Plugin Development
I need to hook the url method to change it to the s3 location, but if i have a local file field its url changes too. Can i hook the url method of only my field? Currently i'm adding the hook to the inputfield class in the init method: public function init() { parent::init(); $this->addHookAfter('PagefilesManager::url', $this, 'newURL'); } protected function newURL($event) { $ssl = ($this->useSSL) ? 'https' : 'http'; $domain = $this->domain(); $event->return = "{$ssl}://{$domain}/" . $event->object->page . "/" . $event->object->name; } The fieldtype and inputfield classes extend the default fieldtypefile and inputfieldfile classes. -
Ok, thanks.
-
How can i add a repeater field in a module's config?
-
$wire = $this->wire(); $this is only used inside a class. http://stackoverflow.com/questions/1523479/what-does-the-variable-this-mean-in-php
-
Just came across this article https://kinsta.com/blog/language-spam/.
-
I use $page->comments->renderForm($args) to display the form and when someone clicks reply a new comment form is added below, this form has a hidden input with the parent id.
-
This is how i do it: function getComments($comments, $page, $parentID = 0, $reply = true, $child = null) { $out = ""; foreach($comments as $comment) { if($comment->parent_id == $parentID) { $reply = ($reply == true) ? "<a class='CommentActionReply comment-reply-link' data-comment-id='{$comment->id}' href='#Comment{$comment->id}'>Reply</a>" : ""; if($comment->status < 1) continue; $cite = htmlentities($comment->cite); $text = htmlentities($comment->text); $userID = $comment->created_users_id; $u = wire("pages")->get($userID); $name = ($u->displayName) ? $u->displayName : $u->name; $date = date('m/d/y g:ia', $comment->created); $out .= " <div class='{$child}'> <article id='comment-{$comment->id}' class='comment-body single-comment'> <header class='comment-meta'> <img src='{$u->avatar->size(75,75)->url}'> <strong>{$name}</strong> <a href='{$page->httpUrl}#comment-{$comment->id}' title='Link to comment' class='comment-link'><time datetime='comment_date'>{$date}</time></a> </header> <div class='comment-content'>{$text}</div> {$reply}"; $out .= "</article>"; $out .= getComments($comments, $page, $comment->id, false, "child-comment"); $out .= "</div>"; } } return $out; } // and use in the template file echo getComments($page->comments, $page); If you have trouble understanding let me know and i'll explain, going to sleep now.
-
You're using <?php require("readsql.php"); ?> inside a php file right?
-
I don't think this is the place to ask which cms you should choose. It's PW forum and i doubt there will be people who'll tell you you should use another cms. I doubt there is something you can't build with PW, or the others cms too, the questions is which one is the easiest to work with.
- 10 replies
-
- 5
-
With AdminOnSteroids the delete checkbox position absolute is overwritten. Can you make the css selector more specific or use !important? .Inputfields .InputfieldFieldset li[class*="Inputfield_delete_"] { position: absolute!important; }
-
https://processwire.com/api/selectors/ http://processwire.com/api/fieldtypes/comments/ For categories see here
-
@Alfred You can hide a field from it's settings page, input tab > visibility.
- 7 replies
-
- hook
- inputfield
-
(and 1 more)
Tagged with:
-
Fieldtype/inputfield for uploading to aws s3 module
fbg13 replied to fbg13's topic in Module/Plugin Development
Think i managed to understand what the InputfieldFile ___processInput does. It passes the name of the file type field to the WireUpload class which takes the $_FILES array and uploads the files from the field with the matching name. So $input doesn't have the files, meaning i can/have to use the $_FILES array. -
Fieldtype/inputfield for uploading to aws s3 module
fbg13 replied to fbg13's topic in Module/Plugin Development
@Robin S Yes i saw some of those, but it's not quite what i try to achieve. I can upload the files to S3 if i use the $_FILES array directly. I just don't know if that's ok, i thought i could use the $input variable passed to ___processInput(WireInputData $input), to get the files, like i can get the value from a text field. -
Fieldtype/inputfield for uploading to aws s3 module
fbg13 replied to fbg13's topic in Module/Plugin Development
I changed the type to text and $this->message($input[$this->name]); returns the value for text field but not for file field public function ___processInput(WireInputData $input) { // this displays the value of the text field after the page was saved, // but if the field is of type file i get nothing // this->name is the name of the field // // $this->message( $_FILES[$this->name] ); - this does displays the array $this->message($input[$this->name]); return $this; } The values are not saved in the db so the text value comes from the input, which makes me think that ___processInput is where i should get the values from the field, process them and save them to the db. Why $this->message( $input[$this->name] ); doesn't work for file type fields? What am i missing? -
I trying to build a module for uploading files to aws s3, but i'm stuck as i can't figure out how everything works just by looking at the FieldtypeFile and InputfieldFile (and others) modules. I managed to display the field on the page, but i can't understand how to access and upload/store the files i select. This is what i have so far, the FieldType The InputField This "$this->message($_FILES['s3']);" inside the ___processInput method gives me the $_FILES array but i'm don't think that's the way to do it. So how and where am i supposed to access the $_FILES array? Are there other methods i need to implement?
-
Works now. One suggestion: add a link to the code mirror theme demo page.
-
@matjazp i can confirm the fact that the page is not created, tested on both windows 10 and debian 8 with PW 3.0.40 and PHP 5.6 It worked with version 1.5.4.
-
Get/Echo another Template depending ond Viewport/Device
fbg13 replied to ForgottenCat's topic in Getting Started
-
<input type="code" class="form-control" id="code"> Don't think code is valid type.
-
I didn't see you code $filter = ""; if($input->urlSegment1 == "femmes") { $filter = ", civilite=mademoiselle|madame"; } if($input->urlSegment1 == "hommes") { $filter = ", civilite=monsieur"; } // you just add $filter to your selector // $filter is empty unless you have an url segment $children = $page->children("limit=12 {$filter}"); $pagination = $children->renderPager(); foreach($children as $child) { $thumb = $child->joindre_au_maximum_4_photos->first()->size(200,200); echo "<div><a href='$child->url'>"; echo "<img src='$thumb->url' width='$thumb->width' height='$thumb->height' /></a>"; echo "<p><strong><em>$child->votre_pseudo</em></strong><br />$child->pays</p></div>"; } I used $results just as an example, in your code you extend your default selector with some extra checks based on the url segment. If you have multiple fields you need to filter by you could use two url segments like this $filter = ""; if($input->urlSegment1 && $input->urlSegment2) { // first segment is the field name // second segment is the value // so the url might be like /fr/annuaire-des-books/mannequins-modeles/civilite/madame // or like /fr/annuaire-des-books/mannequins-modeles/other_field/some_value $filter = ", $input->urlSegment1=$input->urlSegment2"; } // you just add $filter to your selector // $filter is empty unless you have an url segment $children = $page->children("limit=12 {$filter}"); $pagination = $children->renderPager(); foreach($children as $child) { $thumb = $child->joindre_au_maximum_4_photos->first()->size(200,200); echo "<div><a href='$child->url'>"; echo "<img src='$thumb->url' width='$thumb->width' height='$thumb->height' /></a>"; echo "<p><strong><em>$child->votre_pseudo</em></strong><br />$child->pays</p></div>"; } Of course you can check for specific values of the segments and build the selector accordingly.