-
Posts
11,185 -
Joined
-
Last visited
-
Days Won
372
Everything posted by adrian
-
Bill, Are you aware of the difference between single and multiple image fields? Check the "Maximum files allowed" field on the details tab of your image field. If it is set to anything but "1" then you will need to do something like: <?php echo $image1_cover->first()->url; ?> If it is "1", then you must omit the "first()" I have used "url" as I would imagine that you don't really want "filename" as it would look something like: /var/www/root_folder/site/assets/files/xxxx/filename.jpg Does that help?
-
Repository of php Scripts for Templates
adrian replied to thetuningspoon's topic in Wishlist & Roadmap
I just wanted to add my vote for this functionality. Seems like it might be a fairly easy modification, or perhaps addition to the code that runs the modules directory. Of course it would also be awesome to also be able to browse these snippets through the PW admin like the modules manager. -
I was initially thinking about storing a formatted number as an extra field so you could simply do: $page->fieldname->formatted_number, but for the sake of flexibility and reducing database redundancy, I went with leaving the formatting to the output. Any thoughts on this? Now I am thinking that maybe I could go with something like the datetime field type's Output Format options and set up a few common formats to choose from as the default output, or the ability to define a custom output format in the field's details tab. This has been done and is now described in the initial post above. Maybe getting carried away now , but also thinking about detecting the end user's country and determining whether the country code needs to be added to the front-end output or not. Any thoughts / ideas?
-
Phone Number Fieldtype A new fieldtype to enter phone numbers with 4 integer values for country, area code, number and extension and format the output based on predefined or custom options. StyledOutput The most common usage option will be: echo $page->fieldname //eg. +1 (123) 456-7890 x123 This provides a fully formatted phone number, based on the output format chosen from module's configuration page, or with the format override option (if enabled), when entering a phone number on a page. This is a shortcut that produces the same output as: echo $page->fieldname->formattedNumber //eg. +1 (123) 456-7890 x123 Alternate styled options are: echo $page->fieldname->formattedNumberNoExt: //eg. +1 (123) 456-7890 echo $page->fieldname->formattedNumberNoCtry: //eg. (123) 456-7890 x123 echo $page->fieldname->formattedNumberNoCtryNoExt: //eg. (123) 456-7890 echo $page->fieldname->unformattedNumber: //eg. 11234567890123 echo $page->fieldname->unformattedNumberNoExt: //eg. 11234567890 echo $page->fieldname->unformattedNumberNoCtry: //eg. 1234567890123 echo $page->fieldname->unformattedNumberNoCtryNoExt: //eg. 1234567890 Of course the actual output is determined by the selected format output Raw Output You can output the values for the component parts of the phone number like this: echo $page->fieldname->country; echo $page->fieldname->area_code; echo $page->fieldname->number; echo $page->fieldname->extension; Output for mobile compatibility To get iOS and other mobile platforms to recognize numbers and be able to automatically dial them, use something like this: echo '<a href="tel:+'.$page->fieldname->unformattedNumberNoExt.'">'.$page->fieldname->formattedNumber.'</a>'; Selectors for searching The component parts can be used in selectors like this: $pages->find("phone.area_code=123"); Field Settings There is a field settings for the width of the inputs in pixels. There is a field settings for the width of the inputs in pixels. You can also choose whether to display the country and extension fields for input. Off by default. There is an additional checkbox that determines whether there is an option to override the default format option on a per entry basis, which will be useful when styling phone numbers from different countries on the one website. Off by default. Custom formatting options On the module's configuration page you can choose from predefined formats, or create custom formats using syntax like this: {+[phoneCountry] }{([phoneAreaCode]) }{[phoneNumber,0,3]-}{[phoneNumber,3,4]}{ x[phoneExtension]} which generates: +1 (123) 456-7890 x123 Each component is surrounded by { } The names of the component parts are surrounded by [ ] Two comma separated numbers after the component name are used to get certain parts of the number using php's substr function, allowing for complete flexibility. Anything outside the [ ] is used directly: +,-,(,),x, spaces, etc - whatever every you want to use. There are lots of complicated rules around numbers changing when dialed from different locations. A simple example is for Australia. When dialing from within Australia, area codes start with a 0, but when dialing from another country, the 0 must be omitted. You can write a simple format to handle this. The following truncates the first number from an Australian two digit area code: {+[phoneCountry] }{([phoneAreaCode,1,1]) }{[phoneNumber,0,4] }{ [phoneNumber,4,4]}{ x[phoneExtension]} which generates: +1 (7) 1234 5678 x123 even though the full "07" is stored in the area code field. Where to get Available from github: https://github.com/adrianbj/FieldtypePhone And the modules directory: http://modules.processwire.com/modules/fieldtype-phone/ To Do Need to increase the number of pre-defined formats. There seem to be so many options and no real standards, so I thought rather than create a huge list of options that no-one will use, I thought I'd wait and get you guys to contribute them as you need them. Either post your formats here, or send me a PR on github and I'll add them. How to install Download and place the module folder named "FieldtypePhone" in: /site/modules/ In the admin control panel, go to Modules. At the bottom of the screen, click the "Check for New Modules" button. Now scroll to the FieldtypePhone module and click "Install". The required InputfieldPhone will get installed automatically. Create a new Field with the new "Phone" Fieldtype. Choose a Phone Output Format from the details tab. Acknowledgments This module uses code from Soma's DimensionFieldtype and the core FieldtypeDatetime module - thanks guys for making it so easy.
- 138 replies
-
- 15
-
-
I guess my main concern is that dimensions for things are rarely whole numbers (integers), so I am not sure how useful the module can be in its current form. Maybe not an issue in the metric world (where I was born and raised) where you could specify dimensions in millimeters, but now that I live in a backward imperial country (practically, although not officially), and we are stuck with inches as the smallest unit of measurement, it becomes a problem. I am not completely convinced on these multiple input field types. I have always set up dimensions as three separate fields and done the calculations at runtime (I also don't like the redundancy of storing calculated values), but I was looking for a way to use the volume in a selector and thought this might be a good approach. Makes me wish for the ability to do math and apply other calculations / functions to the items in a query, but you have heard my thoughts on that before EDIT: Apologies - I just properly read and understood your instructions - you are saying to store as 538 and format on output to 5.38
-
Hey Soma, Just curious why your module only supports integers. I'll probably modify for my needs, but am wondering if there was some reason I am overlooking.
-
Your first non-working code block doesn't foreach through the $languages array and so $language is probably never defined. As for the variables being printed in the double quotes - that is how php works. In double quotes it works as is. In single quotes you need to do something like: echo '<li><a href="'.$page->url.'">'.$language->title.': '.$page->title.'</a></li>'; Hope that helps.
-
Weird. Actually now that I think about it, I assume the error you were getting was in the admin, and not on a front-end page, so it shouldn't matter what version of jquery you set in your front-end templates. Not sure why that module is causing that problem though - it works fine for me.
-
Suggests to me that you are running a newer version of jquery that no longer supports "live". Have you replaced the script code for jquery or are you using the default that comes with the default PW profile?
-
Not sure if it will work in this case, but have you tried an apache based solution: https://www.google.com/search?q=php+subdomain+session&oq=php+subdomain Some of those results suggest apache and others make use of php options. Might be something in there of use.
-
Assets not accessible - sometimes/mobile devices???
adrian replied to r2d2's topic in General Support
Sounds to me like the cms subdomain is not accessible outside your network which is why you can't access it on your mobile device and we can't access it at all. -
Hi and welcome to PW. Simply set up a new permission called: page-publish and make sure that is checked for the admin user's role and unchecked for the others.
-
Attaching iteration number to foreach-generated HTML-tags.
adrian replied to NoDice's topic in Getting Started
Not exactly sure what you are after, but a typical approach to numbering is: $i=1 foreach($items as $item){ echo '<li>Item#' . $i . ': ' . $item->title . '</li>'; $i++; } Hope that helps. EDIT: Just saw your second post, and I don't think I really understood what you are looking for. It sounds like you want to generate the number via the admin, rather than on the front-end. Is that correct? -
I know this doesn't really solve your issue, but it is another tool that you might be able to make use of: http://modules.processwire.com/modules/page-list-image-label/
-
Ordering by date reversed, then time normal order
adrian replied to adrian's topic in General Support
Excellent - I am not sure the best way to achieve this yet, but if you can make it possible to hook into the selector parser, I would happy to have a go a writing a module that allows for using SQL directly in selectors, or at least using mysql function/operators. Not sure the best option yet. The former could be very powerful, but obviously more complex to integrate without problems. I'll have to start looking through the core and getting an idea how the parser works. -
Hey Ryan, Thanks very much for taking care of this change. Regarding the title limit - every time I have installed PW with the default profile or the new Foundation profile, the title field already has maxlength set to 255, not 2048. Here is the relevant line in the install.sql file: INSERT INTO `fields` (`id`, `type`, `name`, `flags`, `label`, `data`) VALUES (1,'FieldtypePageTitle','title',13,'Title','{\"required\":1,\"textformatters\":[\"TextformatterEntities\"],\"size\":0,\"maxlength\":255}'); Also, I am not really sure how relevant this is: CREATE TABLE `field_title` ( `pages_id` int(10) unsigned NOT NULL, `data` text NOT NULL, PRIMARY KEY (`pages_id`), KEY `data_exact` (`data`(255)), FULLTEXT KEY `data` (`data`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; I know it is only setting the data_exact key and not the field length, but is there any reason to limit this to 255?
-
Just testing out this module and noticed that the codemirror plugin icons folder is missing, so when you are viewing source, there are 4 blank buttons at the top. Grabbing the icons directory from https://github.com/w8tcha/CKEditor-CodeMirror-Plugin mostly fixes the problem, except the first button image is referenced as searchCode.png, but is named SearchCode.png The other thing I noticed was that codemirror plugin.js file and the lang folder was also missing from this module's installation.
-
Hey Ryan, I just went to install the latest dev for a new site and initially had the DB user permissions incorrect. I received the errors that all the tables etc could not be created, but after fixing the permissions problem, there wasn't an option to redo that step of the install, so I had the start the install again. Everything went fine until I got through to the DB install step again. Then I received a bunch of errors about not being able to create the cache, logs, and sessions directories. Of course these were already created from the previous install attempt, so it was fine to enter the admin account info and proceed, but it might be a confusing error for some users.
-
- 1
-
-
How come PW is not listed on this page: http://www.cmscritic.com/resource-lists/cms-list/
-
Because in the details tab of the customer field you must have it set to "Multiple Pages". Change it to a single option and you won't need first() anymore. You should only have it set to multiple if you want multiple customers assigned to each order.
-
You can definitely access images from other pages. When inserting into a RTE field (either TinyMCE or CKEditor) there is the option to insert an image from any page in the tree. If you are wanting to grab the image from another page using the API, then something like this will work: $image = $pages->get(/page-name/)->imagefield->url; If your imagefield is set to support multiple images you'll need to specify which image you want, eg: first(), eq(x), last() etc. EDIT: Btw, welcome to PW. Be sure to check out these resources: http://cheatsheet.processwire.com/ http://processwire.com/api/fieldtypes/images/
-
I am not sure on your page structure, but looking at your code in more detail, do you need to do something like: $orders = $pages->get('/orders/')->children(); or if this code is in the orders page template, then you could just do: $orders = $page->children(); At the moment your ->get will only return one page - the orders parent. Also, did you try the ->first()->title option?
-
Depending on the setup of your customer field, you'll need either: $c = $quotation->customer->first()->title; or just $c = $quotation->customer->title;
-
Hey Ryan, Any thoughts on incorporating those changes in post#7? I am actually using this on a couple of sites now and if you aren't planning on doing something like this for the core, then I might start thinking about a module. No pressure, just want to make sure I don't forget about this when I do a PW upgrade Thanks, Adrian
-
Ordering by date reversed, then time normal order
adrian replied to adrian's topic in General Support
Hey Soma, Thanks for both examples - I really appreciate you seeing me through on this one! I decided to go with the dummy array for generating the pager links - it works perfectly! and it easily allows me to use either the direct SQL approach, or the original idea I showed in post #2. What I am now wondering is if it would be at all possible to have PW parse a selector that uses a combination of PW selectors and SQL such that you could write something like: $results = $pages->find("template=x, limit=10, sort={ORDER BY DATE(data) DESC, TIME(data) ASC}"); Not sure on the syntax, but the idea is that if the selector parser comes across something inside curly braces (or some other delimiter), it uses that directly in the final SQL query. Maybe in this example you could even leave out the "ORDER BY " as the sort would be inserting that anyway. Maybe this could get way too complex to deal with, so I won't bring it up again