Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by adrianmak

  1. Which format is more portable ? a unix timestamp or a date string representative format ? If i intend to use store a unix timestamp, which data type should be used ?
  2. I declare a date field of a table in datetime type I insert a row of data with a datetime field from time() function however, the datetime field are all 0000-00-00 00:00:00 in the inserted row. Here is the query string. I omitted the serialized array in the following INSERT INTO cdata (cid, inamount, outdata, data_time, creation, modified) VALUES (7,119.74,'serialized array','1278028800','1469442446','1469442446') table schema CREATE TABLE `cdata` ( `id` int(11) NOT NULL AUTO_INCREMENT, `cid` int(11) NOT NULL, `inamount` double unsigned NOT NULL, `outdata` blob NOT NULL, `data_time` datetime NOT NULL, `creation` datetime NOT NULL, `modified` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; $cdata = array(); $data_time = strtotime("2-7-2010"); $time = time(); $type = array ( 'paper' => 65.1, 'plastics' => 8.93, 'aluminium' => 0.51, 'glass' => 33, 'steel' => 2.7 ); $cdata[] = array ( 'cid' => 7, 'inamount' => 119.74, 'outdata' => serialize($type), 'data_time' => $data_time, 'creation' => $time, 'modified' => $time, ); the data_time, creation and modified are declared as datetime type in mysql
  3. isn't it just treat it as plain text string, and the db field declare as, let say varchar type
  4. I ve a fresh pw 2.7.3 installation on fresh installation of ubuntu 16.04 The stock mysql version is 5.7.12 and php version is 7.0.4 However, I got a bunch of sql error during installation
  5. The css framework provided class for gapless columns, how about altering the gutter size between column ?
  6. I did write a custom process module, which is use for manage users My code <?php class ProcessMember extends Process { public static function getModuleInfo() { return array( 'title' => 'Manage Members', 'version' => 1, 'summary' => 'Manage member users.', 'permission' => 'member-admin', 'page' => array( 'name' => 'member', 'parent' => '', 'title' => 'Member' ) ); } public function init() { parent::init(); } public function execute() { $out = ''; $selector = 'template=member-user|user, include=all, sort=name'; $out .= "<div class='container'>"; $out .= "<form action='./' method='post'>"; $out .= "<div style='margin-bottom:10px;margin-top:10px;'><label for='keyword' style='width:100%;font-size:1.25em;'><i class='fa fa-search'></i><strong>Search</strong></label></div>"; $out .= "<div><input class='ui-corner-all' style='width:100%;line-height:2em;font-size:1.5em;' type='text' name='keyword' id='search-box' placeholder='Search...' /></div>"; $out .= "<button style='margin:10px 0;' class='ui-button ui-widget ui-corner-all head_button_clone ui-state-default' name='button' value='Add New' type='submit'><span class='ui-button-text'>Search</span></button>"; $out .= "</form>"; $out .= "</div>"; if($this->input->post->keyword) $selector .= ",name|given_name|surname*=".$this->input->post->keyword; $members = $this->pages->find($selector); if(count($members)==0) { $out .= "No registered member."; } else { $user_role = ""; $table = $this->modules->get("MarkupAdminDataTable"); $table->headerRow(["", "NAME", "GIVEN NAME", "SURNAME", "E-MAIL ADDRESS", "ROLES", "TEMPLATE"]); $table->setEncodeEntities(false); foreach($members as $member) { //if($member->template=="member-user") { if(!$member->approval && $member->template=="member-user") $status = '<strong style="color:red; font-size:1.2em;">*</strong>'; else $status = ""; //} foreach($member->roles as $role) { $user_role .= $role->name.", "; } $user_role = rtrim($user_role,', '); $data = array( $status, $member->name=>$config->urls->admin."../access/users/edit/?id=".$member->id, $member->given_name, $member->surname, $member->email, $user_role, $member->template, ); $table->row($data); $user_role = ""; } $out .= $table->render(); } return $out; } } However I found that there is a button link, which is not come from my process module code Where does it come from? how could I remove it ?
  7. A one more related question regarding the pw in-built admin page search. To search pages by default to name, given_name and surname field, I changed the processsearch settings something like With admin account, I could click and edit of a user. But with the user role I mentioned on OP, the search result of the name field display as a plain text only.
  8. I define another user template (with personal fields) for front-end user. I use the method of user page with multiple template technique, which described in this documentation https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users The new setup for user template is working fine. And instead of using the admin account, I defined another user role to manage these users. The editor role could editor normal basic page There is no action bar shown on the members page However, the editor role could edit member page from the Access->users page editor role with this permission member-user access rights for editor role remark: the user role is editor the new user template is member-user
  9. could I target search by default to a specific template ?
  10. The user page list in admin only show three fields, name, email and roles I added other fields in user page for other user information like date of birth I want to show additional field column in user page list in admin Admin can add additional column in the column tab, but it will not keep permanent when log-out
  11. support plain text string and string with html tag function _t($text, $context = 'general', $textdomain = '/site/templates/_strings.php') { return html_entity_decode(_x($text, $context, $textdomain)); }
  12. tpr method is really good for translation strings across templates. However, with using this method , in a situation of not just translated a one to two words label, but a medium long string with html tag Let's say an message to user In my current implementation, i have this translation code $registration_success_message = html_entity_decode(__("Thank you for registration. <br/><br/>Please wait for account approval from administrator.")); in the template , i will echo $registration_success_message;
  13. A dev. site of a client Currently, the menu navigation structure of the site is, the "Treatment" has 2nd level menu. Ordinary desktop could mouse over to drop-down the sub-menu, and it's parent "Treatment" is a hyperlink to a page too. Now, the client want to make the site mobile friendly, how could i deal with menu navigation ? As there is no mouse over event on mobile device, when a user click "Treatment", it will go directly to a page. The sub-menu will never be opened,
  14. I used wireMail to send website email notification to users. I found that email with asian chars, the email received by user may occur garbage text. web mail client (gmail) In gmail, show original. the text on the email raw header look good. The code I use to send email $mail = wireMail(); $mail->to($settings['paypal']['order_email_notify'])->from('noreply@mydomain.com', 'No-Reply'); $mail->subject($order->member->name.' has placed an order. Order# '.$ordernumber); $email_template = wireRenderFile("partial/email-order-notification-tpl", array('order'=>$order, 'settings'=>$settings, 'user'=>$user)); $mail->bodyHTML($email_template); $mail->send(); The partial/email-order-notification-tpl.php file <?php // This email order template is for administrator for order placement notification $out = ''; $grand_total = 0; $total = 0; $out .= "<html>"; $out .= "<head>"; $out .= "<meta charset='utf-8'>"; $out .= "<meta http-equiv='x-ua-compatible' content='ie=edge'>"; $out .= "<title>Order</title>"; $out .= "<style>"; $out .= "table {width: 500px;}"; $out .= "thead {font-weight:bold;}"; $out .= "tfoot tr td:first-child {text-align: right;}"; $out .= "tr td:last-child {text-align: right;}"; $out .= "tbody tr:nth-child(even) {background: #eee;}"; $out .= "tbody tr:nth-child(odd) {background: #ddd;}"; $out .= "thead tr {background: #6d95e0;}"; $out .= "</style>"; $out .= "</head>"; $out .= "<body>"; $out .= "<p>Dear, Admin</p>"; $out .= "<p>Member <strong>{$order->member->name}</strong> is placed an order on ".date('d-M-Y H:i:s', $order->order_time)."</p>"; $out .= "<p><strong>Member number:</strong> {$user->member_number}</p>"; $out .= "<p><strong>Member name:</strong> <span style='text-transform:uppercase'>{$user->surname}</span> {$user->given_name}</p>"; $out .= "<p><strong>Order number:</strong> {$order->title}</p>"; $out .= "<p><strong>Order date:</strong>".date('d-M-Y H:i:s', $order->order_time)."</p>"; $out .= "<p><strong>PayPal Transaction Id: </strong>{$order->paypal_transaction_id}</p>"; $out .= "<p><strong>Payment method: </strong>{$order->payment_method}</p>"; $out .= "<h3>Order details</h3>"; $out .= "<table width='100%'>"; $out .= "<thead>"; $out .= "<tr>"; $out .= "<td>Item</td>"; $out .= "<td>Qty</td>"; $out .= "<td>Price</td>"; $out .= "<td>subtotal</td>"; $out .= "</tr>"; $out .= "</thead>"; $out .= "<tbody>"; foreach($order->order_items as $item) { $p = $pages->get($item->product_id); $out .= "<tr>"; $out .= "<td>{$p->title}<br/>{$p->body}</td>"; $out .= "<td>{$item->product_quantity}</td>"; $subtotal = $item->product_price * $item->product_quantity; $total += $subtotal; $out .= "<td>{$item->product_price}</td>"; $out .= "<td>".number_format($subtotal)."</td>"; $out .= "</tr>"; $grand_total += $total; } $out .= "</tbody>"; $out .= "<tfoot>"; $out .= "<tr>"; $out .= "<td colspan=3>"; $out .= "subtotal:"; $out .= "</td>"; $out .= "<td>".number_format($total)."</td>"; $out .= "</tr>"; $out .= "<tr>"; $out .= "<td colspan=3>"; $out .= "shipping:"; $out .= "</td>"; $out .= "<td>0</td>"; $out .= "</tr>"; $out .= "<tr>"; $out .= "<td colspan=3>"; $out .= "Grand total:"; $out .= "</td>"; $out .= "<td>".number_format($grand_total)."</td>"; $out .= "</tr>"; $out .= "</tfoot>"; $out .= "</table>"; $out .= "<p><strong>"."Terms and Conditions"."</strong><br/>"; $out .= $settings['terms_and_conditions']['eng']."</p>"; $out .= "</body>"; $out .= "</html>"; echo $out;
  15. Currently, I have translation strings across different template files. I experienced that, it is not convenience for text translation, as it required user to log-in at the pw's admin back-end. And any one of the default language text changed, you have to re-translated on the other languages. Therefore, I'm going to change this translation method. I will put all translation strings on a single file, the structure will look like and may include in _init.php $transationArray = array(); $transationArray['default']['text_message_1'] = "FEFDDFG@#@"; $transationArray['default']['text_message_2'] = "565@@DFSS"; $transationArray['default']['text_message_3'] = "ZXCDF@#$$##"; $transationArray['jpn']['text_message_1'] = "$%$%$@#$#"; $transationArray['jpn']['text_message_2'] = "HGH$%$%$"; $transationArray['jpn']['text_message_3'] = "%$%$%$%$"; Then in any of template file, $stringTranslated = $translationArray[$user->language->name]; The rest of the code I just use following to display the multi-language text string $content .= $stringTranslated['text_message']; My question is, for the original translation string in the template files, Besides removing all the translation string variables, how could I remove from dataabse ? Are the translated strings stored in database ?
  16. There is a member template which has a checkbox approval field. When user login, this field will be checked. if true the login session will go ahead otherwise a message will display "your account is not approved yet". To approve a member, administrator will update this field at the pw backend admin ui. Something like that When a page saved, a email will send to the user to notify your account is approved. I add a page saved hook in /sites/ready.php But how could I get the admin form data ? /sites/ready.php function isMemberUserTemplate($tpl) { return ($tpl == 'member-user'); } $pages->addHookAfter("saved", function($event) { $page = $event->object; $is_MemberUser = isMemberUserTemplate($page->template); if ($is_MemberUser) { // how to get the admin form page approval field ? } });
  17. I could find there are number of mobile detection method, server side or js client side. Once detected and forward to a mobile sub-domain, how to make pw to use another set of output template files for mobile ?
  18. A client requested for website required mobile friendly. Instead of using responsive design, I want a separate theme for mobile devices. I'm thinking of, if a user visit the website e.g. http://www.mydomain.com When the website detected a mobile users (How ?), the user will be redirect to a mobile site http://m.mydomain.com , and of course it is using a theme designed for mobile Any how and what ingredients to make it happen ?
  19. I added a field to user template, name status. it has two values, approved and non-approved. Restricted pages could be reached if that field is approved. The website is opened for public registration, and the default value of that field is non-approved. The approval process is manually and it is approved by site administrator When a site administrator changed the field value to approved, I want to trigger a email notification to that user to tell him/her, your account has been approved, you can now login or access our member area blablabla. I want to write a simple module to implement my needs. But I'm not sure which hook should it focus on ?
  20. If you are on Windows platform, you shouldn't miss Virtual cable this piece of software for a DAW (digital audio workstation). It is powerful audio virtual mixer on Windows, and it is a donation free software There are tons of tutorials made from others on the youtube.
  21. For a complex site, it is not the case the navigation is stick on the page tree list hierarchy structure. The navigation menu link may be from different section of a site. I knew there is a pw menu builder module, drag and page freely to build a navigation menu. However, the module is a bit too much of feature provided for user. I could find an alternative solution using the pw code Page field type. You can add another pages. However the main cons of page field is , it only represent first level of navigation, it cannot present sub-level. That's all page add into the page field are on the same level Page field page1 page2 page5.1 page5.2 page5.3 page3 page4 From page field , page5.1, 5.2, and 5.3 are on same level, but they are child of page2. So, When I transverse the page array, I could not build a menu item with child menu items
  22. how to use devdocs to search pw's api?
  23. I'm now playing around with the profields pagetable . It can generate auto page name automatically but it is not for title, so any title will be blanked.
  • Create New...