-
Posts
33 -
Joined
-
Last visited
-
Days Won
1
Everything posted by LeiHa
-
Oh yes it is. It is showing '2' on the first line. Indeed, I named 'admin' for the default superuser when I installed PW at the first time. I guess this is why I got stuck. Thank you so much to help me, adrian. =D
-
Thanks for your interest, adrian. I've tested the code adrian suggested above at the home page. Created User: admin Error: Call to a member function getThumb() on a non-object (line 38 of C:\wamp\www\site\templates\home.php) And tested on the sub page of the home, which named 'test'. Created User: admin Created User Thumb: /site/assets/files/41/thumbnail_contact_img.jpg Current User: admin Current User Thumb: /site/assets/files/41/thumbnail_contact_img.jpg Seems working fine this time. Thank you so much. =D
-
Okay, I don't know why, but, img_user field is the CropImage and single image only. Some page works fine, some other page doesn't work. I've tested code below. $createduser = wire("page")->createdUser; echo $createduser->name; // is it showing the user you expect? echo $createduser->img_user->getThumb('thumbnail'); echo ' ' . wire('user')->name; echo wire('user')->img_user->getThumb('thumbnail'); At the home page, this code doesn't work. Result shows like this. testadmin Error: Call to a member function getThumb() on a non-object At the any child page of home page, Everything works fine. I guess this must be caused some other place. Thank you guys.
-
What I was trying to do is to put user image thumbnail on the user. Whenever showing a post, user image thumbnail should be displayed along with a post. And I didn't know what caused the problem before. Thanks to apeisa. I got to narrow down the problem. wire('user') pull out the current user information. Now that, I also need to pull out current logged in user information. So that I can get the current user image thumbnail on the writing new post page, that current user is about to create. But, somehow, I got an error. And I'm thinking this causes error on my code. Thank you all. It is so grateful.
-
Thanks apeisa. taking out of eq(0) makes work fine. I've been testing some of this issue with different way. $createduser = wire("page")->createdUser; echo $createduser->name; // is it showing the user you expect? echo $createduser->img_user->getThumb('thumbnail'); Since this works, I've put wire('user') on the first line. $createduser = wire("user"); echo $createduser->name; // is it showing the user you expect? echo $createduser->img_user->getThumb('thumbnail'); This time, I got an error. Error: Exception: Method Pageimages::getThumb does not exist or is not callable in this context
-
Oh, I didn't notice that point. Fixed and works well this time. But, I'm still having issue with thumbnail. $createduser = wire("page")->createdUser; echo $createduser->name; // is it showing the user you expect? echo $createduser->img_lg->eq(0)->getThumb('thumbnail'); added to get a thumbnail url above and got a error message. Error: Exception: Method Pageimage::eq does not exist or is not callable in this context (in C:\wamp\www\ktest\wire\core\Wire.php line 232) #0 C:\wamp\www\ktest\site\templates\test.php(57): Wire->__call('eq', Array) #1 C:\wamp\www\ktest\site\templates\test.php(57): Pageimage->eq(0) #2 C:\wamp\www\ktest\wire\core\TemplateFile.php(125): require('C:\wamp\www\kte...') #3 [internal function]: TemplateFile->___render() #4 C:\wamp\www\ktest\wire\core\Wire.php(271): call_user_func_array(Array, Array) #5 C:\wamp\www\ktest\wire\core\Wire.php(229): Wire->runHooks('render', Array) #6 C:\wamp\www\ktest\wire\modules\PageRender.module(250): Wire->__call('render', Array) #7 C:\wamp\www\ktest\wire\modules\PageRender.module(250): TemplateFile->render() #8 [internal function]: PageRender->___renderPage(Object(HookEvent)) #9 C:\wamp\www\ktest\wire\core\Wire.php(271): call_user_func_array(Array, Array) #10 C:\wamp\www\ktest\wire\core\Wire.php(229): Wire->runHooks('renderPage', Array) #11 C:\wamp\www\ktest\wire\core\Wire.php(293): Wire- This error message was shown because you are logged in as a Superuser. Error has been logged.
-
well. That didn't work. Nothing shows on the screen. But, this works below. wire("page")->createdUser->name; This properly shows as expected, which is 'admin'. I guess there is something wrong with it. Thanks Ryan.
-
Hey guys. Have some question here. I've put img_user field on the user to add thumbnail image. And this code works perfectly well as expected. echo $user->img_user->eq(0)->getThumb('thumbnail'); However, I need to use this code my custom made function in it. So, I've tried several way to work out. echo wire('page')->createdUser->img_user->eq(0)->getThumb('thumbnail'); Now, using createdUser doesn't seem to work here. Any idea what would be the problem in here? Thank you =D
-
Hello forum, I'm here to get a help again. This time, I'm having a trouble with ajax data. Sending a data into the same page seems okay. However, Sending a data into the different page seems not working. I don't know why. Here is the jquery code. $.ajax({ url: url, type: 'POST', data: { from: 'thispage' }, success: function(data){ alert(data); } }); If url is './' I can get this value from $input->post->from This value returns 'thispage' as expected. If url is '/different/page' I won't get this value from the above $input->post->from It seems url has to be a file, Processwire template and page created somehow. Otherwise, it won't be processed because of permission issue. So, I created template and a hidden page just for the processing ajax. Any idea what would be wrong? Thanks.
-
Hello, Looking for a PW developer. Here is my situation. I've been trying to create a game community site using PW. And it's been 6 months and still working on it. Because of my lack of web programming knowledge, I've been having hard time figuring out all the web programming such as PHP, JavaScript, jQuery, and PW. If anyone of you can help me out, I'll be so grateful. Here are the list I need to have my site. 1. module for a community forum system 2. module for a front-end profile system work with forum 3. module for a registration system 4. security system such as IP block or something like this Feel free to contact me with proposal. Here is my email address. hyotakdesign@gmail.com Thank you PW community letting me know great the PW. LeiHa
-
Thanks all of you. I'm starting to understand a bit. I'll look up Jquery UI roller site and see how things work. Thank you.
-
Sorry about the confusion. I'm still trying to understand how to implement this in the frontend site. The message system in admin backend site seems wonderful and I'd like to use it in the frontend. At first, I thought that I could just use $this->error('some text'); or $this->message('some text'); in the frontend. Eventually those didn't work of course. And tried to find out how to use this system(I assume Ryan made this. So impressive!!!)
-
I've found out that I actually have to put this code below. <?php if(count($notices)) include($config->paths->adminTemplates . "notices.inc"); ?> This code is from default.php from admin files.
-
I've been building message and error system. And I've noticed that PW uses Jquery highlight message system, which is very easy to use. Some of PW module do this like, $this->message('message here'); $this->error('error message here'); And it seems like automatically generate markup for the Jquery to handle.(If I understand correctly) So, are message and error methods only for use inside of class? If I'm not getting it, please let me know. Thank you.
-
omg it works finally. Thank you Martijn and you all.
-
So, I've tried what Wanze suggested above. And I got this error. Uncaught TypeError: Cannot set property 'rememberTabs' of undefined localhost:31 (anonymous function)localhost:31 Uncaught TypeError: Cannot read property 'rememberTabs' of undefined JqueryWireTabs.js:13 $.fn.WireTabsJqueryWireTabs.js:13 (anonymous function)main.js:4 cjquery.min.js:3 p.fireWithjquery.min.js:3 b.extend.readyjquery.min.js:3 H
-
Thanks Wanze. Didn't know how to check the error handling. I've checked several times and the css and js are loaded fine. But, I got the js error on the console screen. Uncaught ReferenceError: config is not defined So, I must do something wrong.
-
Sorry guys, I'm still not getting it. In order to work JqueryWireTabs, I think that it should be $module->get('JqueryWireTabs'); And associated js and css file to link. Is this right? Structure is like $form = $modules->get('InputfieldForm'); $form->action = "./"; $form->method = "post"; $form->attr('id', 'site_settings_form'); $siteWrapper = new InputfieldWrapper(); $siteWrapper->attr('title', 'Site'); $forumWrapper = new InputfieldWrapper(); $forumWrapper->attr('title', 'Forum'); $field1 = $modules->get('InputfieldText'); $field1->label = 'Site Title'; $field1->columnWidth = 100; $field1->attr('name', 'site_title'); $field1->attr('value', $pages->get('/site-settings/')->site_title); $button = $modules->get('InputfieldSubmit'); $button->attr('value', 'Save'); $button->attr('name', 'save'); $siteWrapper->append($field1); $siteWrapper->append($button); $form->append($siteWrapper); $forumWrapper->append($field1); $form->append($forumWrapper); echo $form->render(); And Jquery code below $('#site_settings_form').WireTabs({ items : $('#site_settings_form > .Inputfields > .InputfieldWrapper') }); If I miss something in here, feel free to tell me. Thank you.
-
Thanks, Ryan and Martjin. I'm starting to understand how this works. However, it seems there is some missing point to work properly. And I've found out what Soma said earlyer. This should work within a module class. And JqueryWireTabs is not working without this line. (don't know why) If anyone knows how to put this line together at the template php file, that would be great help. Thank you. =D
-
I have a question here if you guys don't mind. Is it possible I can use these outside of module? I mean in template php file. I simply don't know how to do this. I've tried $modules->get('JqueryWireTabs'); (because code is in template php file.) but this is not working somehow. Thank you. =D
-
Thanks for all your interest on me. This is wonderful learning process using Processwire. I really appreciate it. I've got here so far because of all of talented people in this forum. Thank you.
-
Hello guys. Just let you know that I'm still learning php, javascript, and Processwire. This time, I'm trying to do the image upload, and been look through this forum how to do it. Unfortunately, some of the way people did in this forum are totally not understandable, yet. What I found out is how this is process. Hope people like me would find this post and help through creating wonderful website. I'll only use php and Processwire API because I don't know about the jQuery enough, yet. 1. create form <form class='forum-form' accept-charset="utf-8" action='./' method='post' enctype='multipart/form-data' > ... <input type='file' id='attach' name='attach_file' multiple='multiple' accept='image/jpg,image/jpeg,image/gif,image/png' /> // this is the input tag for the image attachment <input type='submit' name='add_file' value='Add file'/> // this is the submit to upload image attachment before submitting entire form <input type='submit' name='form_submit' value='Submit'/> // this is the submit to send entire data ... </form> I found out that I have to put enctype='multipart/form-data' in order to submit file/image type. 2. To attach some images on the page, I guess, I have to upload those images before submitting form. PHP code seems very complicated to me, and I've found out that it is somewhat easy to use Processwire class which is WireUpload. I've made a custom function so that I can reuse and maintaining easily. I've borrowed Soma's code here.(hope this would be fine with him) private function uploadImage(){ $upload_path = $this->config->paths->root . 'tmp_uploads/'; $u = new WireUpload('attach_file'); $u->setMaxFiles(1); $u->setOverwrite(false); $u->setDestinationPath($upload_path); $u->setValidExtensions(array('jpg', 'jpeg', 'png', 'gif')); $files = $u->execute(); if ($u->getErrors()) { foreach($files as $filename) unlink($upload_path . $filename); foreach($u->getErrors() as $e) echo $e; } else { foreach($files as $filename){ $upload_path = $this->config->urls->root . 'tmp_uploads/' . $filename; $this->session->attach_markup .= $this->attachMarkup($upload_path, $filename); $_SESSION['files'][] = $filename; } } } I've changed temp directory name without a dot.(couldn't create starting a dot in WIndows system). Also that I found out Processwire API doesn't automatically create a folder, so I just manually create a folder in Windows. I can change setMaxFiles later, but for the test purpose, set this to 1. I've decided stick on setting max file upload 1 at a time. If I want to upload more file, simply run this function I guess. I couldn't figure out how to put array data on the PW session. So, I just used php session code here. Saving markup output data and each filename on the session for later use. private function attachMarkup($upload_path, $filename){ $out = <<< EOS <div> <span>Existing attachment :</span> <a href="$upload_path"> <img src="$upload_path" width='15' height='15' />$filename </a> <input type='submit' name='delete' value='Delete' /> </div> EOS; return $out; This is the attachMarkup function, which receive uploaded file path and file name to create markup. if ($this->input->post->add_file){ $this->uploadImage(); $attached_file = $this->session->attach_markup; } This should upload image file to temp directory. Whenever 'Add file' button is clicked, run this custom function. $attached_file has some markup data covering multiple file uploaded. I can simply use it like this below. <?php echo $attached_file; ?> in the middle of html code. 3. Now that I should move this image to the page. After filled with subject, body, and image files, clicking a submit to send entire form should save all these data on the page. I've used another custom function called processInput. private function processInput() { switch ($post->type) { $newPost = new Page; ............................................// all other fields data to save here such as title, name and so on $newPost->of(false); // put images into the image fields if ($_SESSION['files']){ foreach($_SESSION['files'] as $filename){ $filename_with_path = $this->config->paths->root . 'tmp_uploads/' . $filename; $newPost->forum_images = $filename_with_path; // save image into forum_images field unlink($filename_with_path); $this->session->remove(attach_markup); unset($_SESSION['files']); } } $newPost->save(); } } Because $_SESSION['files'] is the array, I have to use foreach saving each image file onto the page. Using unlink PHP function to remove files I've uploaded to temp directory. Same as attach_markup and $_SESSION['files'] data. It is no longer needed anymore. Once everything are saved correctly, image file data can easily pull out. foreach ($somepage->images_fld as $img) echo "<img class='crbox' src='{$somepage->images_fld->url}$img' />"; From the $somepage that has field named 'images_fld', I can pull out url like $somepage->images_fld->url and filename like I did above. There are some other issues I'm fighting for. If a user go back out from the form page, now that I have to remove session data and uploaded files. Thank you.
-
oh well. I've found out why that didn't work. $page_sent = $this->pages->get($post->fid); $page_sent->of(false); if ($post->type == 'edit_topic') { $page_sent->title = $post->subject; $page_sent->forum_visited_users->removeAll(); $page_sent->forum_visited_users = $user; } else{ $page_sent->parent->of(false); $page_sent->parent->forum_visited_users->removeAll(); $page_sent->parent->forum_visited_users = $user; $page_sent->parent->save(); $page_sent->parent->of(true); } $page_sent->body = $post->message; $page_sent->save(); $page_sent->of(true); $page_sent->of(false); was inside of if statement. I've moved it before the if statement. Now that it works, I still don't understand why. I've put the of(true) after save() I think I should do this. or not. A lot of coding I'm writing on are still confusing. sometimes I don't know what I'm doing. lol Thank you.
-
Thanks, adrian and diogo. I've took diogo's solution. It works perfectly well. I've created Page field to hold user data array and attached to the template I will use. And another integer field to hold view count number and attached to same template. And put this code every time a page loads. if (!$this->page->forum_visited_users->has($this->user)){ $this->page->of(false); $this->page->forum_visited_users = $this->user; $this->page->forum_num_views++; $this->page->save(); } Then, every time page has been edited or deleted, page array reset. And put a current user data in the array so that it doesn't increase view count.(because an user who edit or delete is already read this post) $page_sent->of(false); $page_sent->forum_visited_users->removeAll(); $page_sent->forum_visited_users = $user; One problem is whenever edit or delete reply post, which is a child of topic post, somehow it doesn't work. topic post is the parent of reply post. below code is not working. I don't know why. $page_sent->parent->of(false); $page_sent->parent->forum_visited_users->removeAll(); $page_sent->parent->forum_visited_users = $user; $page_sent->parent->save(); Even though I got new problem, this is a huge improvement. I really appreciate it. Love you guys. Thank you.