Leaderboard
Popular Content
Showing content with the highest reputation on 04/02/2014 in all areas
-
I started with CMSses with MODX revolution and there you had that 'pesky' template language. Sometimes you have to do [[]], then you've to do [{}] and some need a * and others need the exclamation mark. Then on every found info page I had to think, is this for evolution or revolution, is this a snippet or a chunk. And if you want to have a simple if-statement you needed to start a snippet and a chunk as template or had to find plugins who install all kind of other snippets, plug-ins and other 'garbage' to do a simple comparison. If you can handle all that noize while thinking on building a site, you already can code. ( Maybe you don't realize that now ). There are less exceptions in PHP then there is in the MODX language. You can find documentation every where. You just have to start with the basic things. Actually, ProcessWire is the perfect environment to start learning PHP. (could be a little off with the MODX tpl language, I already forgot how to use it)8 points
-
Here are my first couple of sites using PW, critique appreciated! Artists agency Photographer Thanks!7 points
-
You don't need to know much php to use ProcessWire. I recommend the ProcessWire documentation which covers all the php that you'll need to know (initially). The cheatsheet is helpful too. This is about all the php you need to build a simple website in PW. For apps and complex websites you'll need to go further with PHP (specifically objects and methods). if http://www.php.net/manual/en/control-structures.if.php comparison operators http://www.php.net/manual/en/language.operators.comparison.php logical operators http://www.php.net/manual/en/language.operators.logical.php foreach http://www.php.net/manual/en/control-structures.foreach.php array http://www.php.net/manual/en/language.types.array.php find answers to specific problems (a good place to look errors when you don't know what they mean) http://stackoverflow.com/6 points
-
Put in search.php $log->save('querylog', $q) And you'll have a log file querylog with timestamp and queries.6 points
-
There's something called variable scope within a function....Basically, a function is a closed container and is not aware of its surroundings...It only knows the things within it. Hence, you need to show it the outside world. To do that, you need to use some sort of global variable...something that is powerful enough to see the 'outside' from 'within'....that thing in PW is wire So, you can either use: wire('pages')->get();//as a function/method //or $wire->pages->get();//as a variable The same issue of scope arises when dealing with modules/class or bootstrapping PW... By the way, you don't want to be echoing within a function....use return instead (at the end)...before that...you can save stuff that you will want to output in a variable...e.g. $out = ''; //do more stuff...then we add to $out.. $out.= 'this is my cool stuff'; //do more stuff, then append to $out. $out.= 'this is even better man!'; return $out;//you can also do return $out . $another variable . $foo . $bar, etc.. //Call your function and it will output what you return-ed in the function...5 points
-
Just to add a bit of detail to Soma's answer - Don't forget the semi-colon $log->save('querylog', $q); (I did at first.) There's no need to add a file extension, as '.txt' is added automatically. (I did at first.) The file 'querylog.txt' is saved in '/site/assets/logs/' like so '2014-04-02 09:39:24 username http://example.com/search/ searchword'.5 points
-
Please use Matrix Fieldtype & Inputfield Or the ProFields. FieldtypeJson (module) Álpha I've been busy last 2 weeks with a new fieldtype. I needed a fieldtype that generates JSON strings from CSV (excel data). I needed a way to handle a variable amount of columns & needed a way to manage that data. Wanze & Kongondo already worked on a excel crud module with the excellent Excel-like data grid editor Handsontable and I loved that piece of software. Thank you guys. Handsontable is used in the Inputfield part. What the Inputfield does does: If there's no data in the field, the Inputfield shows you a textarea. You could copy 'n past in CSV text in that field. When you save the field, all data is processed. Processing means: Slice till an x amount of data rows. If minimum amount of columns is not reached, pad the columns till the amount you've specified in the settings If the data contains to much columns, slice the redundant amount of columns. Every data left, is trimmed and sanitized Every numbered string will be converted to integers Saved in 2 formats: 1) json and 2) cvs Server side there's a lot of processing needed to perform all this, that is the reason to set a low amount of data rows. On The Inputfield side, the JSON is generated by Handsontable. So this feels a bit dirty. (Server side it does do all the steps in the above list.) For now it's called FieldtypeJson, but i'm not to keen on this name. Output How to output in your template: $page->fieldname // (string) the table markup $page->fieldname->json // (string) JSON string $page->fieldname->csv // (string) CSV string $page->fieldname->rows // (int) number of rows, not really usefull, but needed internally $page->fieldname->columns // (int) number of columns, not really usefull, but needed internally When to use: If you need a small set tabular json data, and you don't know how many columns it has. If you want to have render tables quicky in your site. When not to use: Store very large sets of query -able data. If you have to rely rely on the data. ( all json is stored in a subfield, and the same for csv ) API Side (JSON): // Json string $json = '[["First Name","Last Name","Company Name","Address","City","State","Post","Phone","Email"],["Rebbecca","Didio","Brandt, Jonathan F Esq","171 E 24th St","Leith","TA","7315","03-8174-9123","rebbecca.didio@didio.com.au"],["Stevie","Hallo","Landrum Temporary Services","22222 Acoma St","Proston","QL","4613","07-9997-3366","stevie.hallo@hotmail.com"],["Mariko","Stayer","Inabinet, Macre Esq","534 Schoenborn St #51","Hamel","WA","6215","08-5558-9019","mariko_stayer@hotmail.com"]]'; $page->of(false); // Turn OutputFormatting of $page->fieldname->json = $json; $page->save(); $page->of(true); API Side (CSV): // CSV string $csv = '"First Name","Last Name","Company Name",Address,City,State,Post,Phone,Email Rebbecca,Didio,"Brandt, Jonathan F Esq","171 E 24th St",Leith,TA,7315,03-8174-9123,rebbecca.didio@didio.com.au Stevie,Hallo,"Landrum Temporary Services","22222 Acoma St",Proston,QL,4613,07-9997-3366,stevie.hallo@hotmail.com Mariko,Stayer,"Inabinet, Macre Esq","534 Schoenborn St #51",Hamel,WA,6215,08-5558-9019,mariko_stayer@hotmail.com'; $page->of(false); // Turn OutputFormatting of $page->fieldname->csv = $csv; $page->save(); $page->of(true); After save, all other subfield are updated. So saving JSON will update CSV and the rows and the columns. And saving CSV will update JSON and the rows and the columns. Saving direct to the fieldname, or saving to both json and csv or saving to the rows & columns wil thow a wireException(). Download: source on github Warning: This Fieldtype is Álpha, don't use it in live projects empty field: paste data: imported data: manage data: settings:4 points
-
Hi Max Welcome to Processwire, good to see you here I know you will fall in love with Processwire. I've been meaning to write some newbie tutorials for PW but have been quite swamped with client work and have had some big projects going. But it's still on my to-do list. Processwire is a fantastically flexible CMS to work with, and you can bend it any which way you want, depending on your needs and skills. I dare say it's a lot more flexible than MODX ever will be, and you never need to learn another templating tag in your life You can just fit PW into the way you like to work, which is what would make creating tutorials tricky, since a tutorial would only present one way of doing things My advice is the same as everyone else's. Start with the docs, understand how template files work (http://processwire.com/api/templates/) and then get hands on. Come back to the forums and ask questions when you get stuck, and one day the light bulb will just go on and you'll be on your way There are still things I find quite challenging in PW but I'm constantly learning and building my skillset here, and I'm hoping to very soon have time to document the things I'm learning how I'm learning them. Just jump in, you can't go wrong4 points
-
I did it again http://soma.urlich.ch/posts/custom-js-in-processwire-admin/3 points
-
3 points
-
ProcessWire is easy to get the hang of. If your going to build sites for clients, you will appreciate the differences soon enough. Come on in, the water is nice. BTW: i just finished moving the last of my client sites off MODx (started on 0.95). Most of them I converted on my dime. I did it because It saves me time and is easier for them to manage content. No more dependance on custom modules to get my sites the way I want. Have most everything I need in the core. Dumped drupal for many of the same reasons too. I used to think lots of great third party modules for *some cms* saved us time. Not so. The upgrade problems alone cost us more than the coding in PW. Learn to code. It's a skill that won't be replaced.3 points
-
I concur with letting a payment gateway handle the card processing, PCI compliance is a big deal and a lot of gateways have API's that are easy to implement. In your case, PayPal's API has the IPN (instant payment notification) messaging service that is free for merchant accounts. It sends POST data to the page you specify so you could just point to a page you've created in PW and handle account/page creation after a successful payment has been made. It's done like this: https://developer.paypal.com/webapps/developer/docs/classic/ipn/gs_IPN/ As far as making the deletion of pages automatic, you could try the LazyCron module : http://modules.processwire.com/modules/lazy-cron/ You can test against the creation of the page by using $page->created, it returns a Unix timestamp of the date/time the page was initially created. You can store the anticipated delete time by adding 24 hrs to the $page->created value // LazyCron function on template page function deletingThePage(HookEvent $e) { // Maybe have a checkbox field == 1 to indicate if payment was processed by Paypal // Find all pages with unpaid statuses $unpaidPages = $pages->find("paymentCheckbox=0"); // iterate the results foreach($unpaidPages as $k){ // When the page was created $timestamp = $k->created; // $timestamp + 1 day $deleteTime = strtotime('+1 day', $timestamp); // If the time to delete the page has been met or exceeded if($deleteTime <= time(){ // Delete the page $k->delete; } } } // Add a hook to the function. Check every hour wire()->addHook('LazyCron::everyHour', null, 'deletingThePage'); All pseudo-code - absolutely no promises that any of that works as I've never used the LazyCron module. From what you've listed as requirements, it sounds like you're almost there. Is the PW API the part giving you a hard time or the implementation of using payment gateway API's?2 points
-
Already a bunch of good resources, but here's a couple more: Especially if you're at "absolutely beginner" level, there's a ton of useful video tutorials floating around. This one titled "Learn PHP in 15 minutes", for an example, seems pretty good. For more background there are also more thorough videos, such as this Harvard extension school lecture. Once you get up to speed, you should most definitely take a look at PHP: The Right Way. If you're really into it, I'd strongly suggest Programming PHP from O'Reilly. It's available as an ebook too. Another book worth checking out is Essential PHP Security. Short but good -- if every PHP developer knew at least this much about security best practices, PHP world would be a lot safer place. Just my two cents. Totally random fact: Designing Web Graphics by Lynda Weinman was one of the very first web design books I could get my hands on. That was some fifteen years ago, when quality learning material was still kind of scarce, at least around here. Should probably take another look at that book one of these days, could be sort of fun2 points
-
php.net All functions have example code and other code for different aproach for the functions. http://nl1.php.net/manual/en/function.echo.php2 points
-
Update, i noticed to get this working all it needs is an extra column to the FieldtypePage with the folowing settings. Now i did it manualy to the database. To have it work automaticly for each FieldtypePage field that is added it needs to be added here. $schema['modified'] = 'timestamp NOT NULL default CURRENT_TIMESTAMP'; Then it works and you can request the modified (added) date timestamp this way. foreach($pages->find("template=templateWithInputfieldPage") as $somePage) { echo date("d-m-Y H:i:s", $somePage->modified)."<br>"; } This will spit out the date that page B was added to page A InputfieldPage field. For me this would be a very useful feature for the FieldtypePage. But i'm aware there is a good chance this addition is not that interesting to Ryan or others. So i hope this will make it to the core, but if not does anybody know how to turn this in to a module? One that just adds the extra modified field to each FieldtypePage (InputfieldPage) automaticly?2 points
-
Hi robinc, welcome to the forums. Yes, it is created only one version Only workaround I know is to use the PageImage Manipulator. There you can pass a customdefined prefix to the filenames of image variations. You need to install it and simply add a call to it like: $image->pimLoad('cropped')->pimSave()->size(320, 320, $options); for the second image.2 points
-
Um no, It does save as it should for me. No matter If I specify 1 or 0 as the default in construct, if checked and saved, fname: 1 is saved to db (without the "workaround”) and when I uncheck and save the fname: 1 is cleared and no value in db, as it should. As said, in you don't specify a uncheckedValue it will always be checked, cause there's no value saved for unchecked and on load it will set 1, and not overwrite it as there's no value coming from db.2 points
-
Ok, looked at this situation as I wondered and had similar issues in the past. If you really want to have a checkbox inputfield checked by default in this context you have to use the uncheckedValue, checkedValue property instead to make it work. Following example works fine: $f->attr('name', 'formatting'); $f->attr('uncheckedValue', "no"); $f->attr('checkedValue', "yes"); $f->attr('checked', $this->formatting == "yes" ? 'checked' : ''); This makes sure a unchecked value is saved, instead of nothing. And default in construct then can be $this->set('formatting', "yes");2 points
-
I've used both and pages is the best solution, in my opinion. As Macrura said, the Select AKA Dropdown is only for very simple and small amount of options. What anyone eventually learns is that using pages allows for future expansion, even when you initially think you will only ever need 4 or 5 options. My clients have always liked that they can add options to their fields whenever I use the page method.2 points
-
find will find many (or even all!) things if they exist unless you limit it. This will put a strain on your servers and PHP may even timeout. get, will only get one thing...so, less resource hungry. The general rule is that when using find, you need to use limit=xx. You can always paginate your results if you need more to be fetched. But, if you are sure that the number of children will not grow, and that you have a set reasonable number of children, then you can avoid the limit2 points
-
Using pages for selects: that's your most powerful relational database right there! It gives you access to the whole Page Object or Page Objects that are selected (hence everything about them)...you can even go farther down the rabbit hole...and find out more information about other relations that those selected pages have (other than their relation to the page that has the page field) - their parents, children, etc...This is a very powerful PW feature yet Ryan has implemented it as a very simple, user-friendly and elegant solution... I have never used Select AKA Dropdown - so, no comment...but, horses for courses...2 points
-
Well, to answer your original question... Based on my experience with both systems and a bias for PW, Drupal is actually the right tool for the job in this case. It's a pain in the ass to work with (3 year learning curve is typical) and you'll have more fun using PW (Drupal 8 is actually pretty awesome, but not stable yet). If this was a personal project where time and budget weren't a concern, I'd say use PW. You'll have a better product, because it's custom and built exactly to your needs and it's using a better framework. Since that's not the case, you may be looking at 500 hours of work and testing to implement the remaining features into PW. 1. Has to be tablet and phone responsive. 2. Easy two level nav bar (menu) 3. Has to manage orders as it is a service oriented e-commerce site. Shop for PW looks like 60% of what I need. (Drupal module exists) 4. Need to easily be able to ask the users a series of questions and build an “order” based on the answers. Some of the questions will result in form changes that would ask yet different questions. So I need to look at some good code for DB interaction. Perhaps looking closer at Shop will ramp me up there since the DB interaction I need is all order related. (Drupal module exists) 5. I need to interact with a tool that will calculate mileage from address A to Address B. (Drupal module exists) 6. I need authorize.net payment gateway. (Drupal module exists) 7. Standard social media like/follow 8. Contact Form with email to multiple email addresses. 9. I need to expose the Orders and other order related info to admin users that should only see the order management (none of the standard PW admin). I think I understand what you'd like to do and I believe there is partial support, but not as robust as Drupal permissions (which in most cases is fine). Look at the permissions and role modules. There's a module which adds field permissions and there are some which add page specific permissions.2 points
-
ElasticSearch does a lot, but the part that is most interesting to me is that it does an amazing job of fulltext search. It's also crazy fast. It can be a bit scary at first so hopefully this module will make it more accessible. I threw together this module pretty quickly, it's more of a proof of concept than anything else at this point. I tried it out on a site with 400 bilingual pages and the search results are much improved over the normal search you would get doing like queries or fulltext queries in mysql. Github page: https://github.com/jdart/ElasticSearchProcessWire I'd love to hear some feedback on how it works for you. It's very new so expect bugs, in particular the mechanism that turns pages into data to be indexed by ES might have some surprises.1 point
-
PW Images Manager (beta) Just a weird little screencast trying to show how it works. (out of date a little, tags now use a textfield for easy copy/paste) This module allows you to manage images from one central repository. You create a root page "/images/" where you can then add categories and images as pages. From there the new admin page created "ImagesManager" will show categories and images added in a ajax data table, from where you can see and search/filter all images, upload and create new categories and edit images too. Every image will also show an image tag generated to copy into a textarea. This tag looks like this: {image=/path/to/image/imagename/, width=200}The width=100 is the thumbnail size used to output the image.You can also have additional segment to contain classes: {image=/path/to/image/imagename/, width=100, class=align_left}Or you can enter the id directly: {image=1033, width=100}Once inserted into a textarea field it will get parsed when saved and loaded automaticly. It will store an abstract id tag in Database and convert it back to the image HTML tag. So after first save you'll see the image inserted in a Wysiwyg and be able to resize and place it as usual. Once it's inserted somewhere Images Manager will show a search link with the pages containing the image (you can configure the fields int the module setting). You can change the image or move it to a different category, it will still work and show the correct image. This also works with multi-language fields.You can still also use the regular insert image dialog in TinyMCE and chose image from those pages. And it will start keeping track of those as well (they're the same after all). You can use those central images pages also with page fields to reference them single or even whole categories, search them with API and do what you like. Images Manager will also parse the page render on front-end and replace any found image tags with the HTML code. It will also look for a description on the image and output it as alt tag. If you want to have multi-language description you can add a `image_description` TextLanguage field to the image page template and have images parser use them. Along with this module, you can also install the `PageListImageLabel` module to add thumbnails to the image pages in the tree. To get it working you need to have the basic setup: 1. Create new `image` field with input setting to 1 max image 2. Create new `image` template and add `title` and the `image` field created before 3. Create a 'image-category' template with only title and allow the `image` template and `image-category` as child pages under family settings. 4. Create a `image-root` template with only the title field for the root of the images tree. Allow only `image-category` as child page under family settings. 5. Create the root page with the `image-root` under the home page as "/images/" 6. Done. The structure of the image repository looks like this /images/ /cagetory1/ /imagesxy/ /category2/ /image2/ /image3/ Now you can use the ImagesManager to add categories and images. But you can also still use the page tree to add new stuff as usual. The root path, template names and fields are configurable in the module settings. How to install the module: - Download the contents of this repository and put the folder renamed as "ImagesManager" into your site/modules/ folder - Login in to ProcessWire and got to Modules page and click "Check for new modules". You should see a note that the two new module were found. Install the "ImagesManager" module. - A new admin page "ImagesManager" should appear in the top menu. - You may configure the option on the module screen to suit your needs. Download at github https://github.com/somatonic/ImagesManager Thanks and enjoy.1 point
-
I exported a CSV file from freebase.com that contained all the skyscraper fields I wanted to use. Then I created a simple shell script to import it from the CSV. Note that I only used a shell script for convenience, you could just as easily do this from a ProcessWire template file if you preferred it or needed to do this from Windows, etc. Below is a simplified example of how to do this. The example is fictional and doesn't line up with the actual structure of the skyscrapers site, nor does it attempt to create page relations or import images. If you are interested in how to do that, let me know and I'll keep expanding on the example in this thread. But I wanted to keep it fairly simple to start. First, here is the contents of a CSV file with each line having a skyscraper building name, city, and height. /skyscrapers/skyscrapers.csv (Building, City, Height): Sears Tower, Chicago, 1400 John Hancock Tower, Chicago, 1210 Empire State Building, New York City, 1100 IBM Building, Atlanta, 860 Westin Peachtree, Atlanta, 790 Next, create a new template in ProcessWire and call it "skyscraper". Create a text field for "city", and an integer field for "height" and add them to the skyscraper template. Create a page called "/skyscrapers/" in ProcessWire, that will serve as the parent page for the skyscrapers we'll be adding. Here is the command-line script to load the ProcessWire API, read the CSV data, and create the pages. As I mentioned above, this could just as easily be done from a template, where the only difference would be that you wouldn't need the shebang (#!/usr/local/bin/php -q) at the beginning, nor would you need to include ProcessWire's index.php file. /skyscrapers/import_skyscrapers.sh: #!/usr/local/bin/php -q <?php // include ProcessWire's index file for API access // (this isn't necessary if you are doing this from a template file) include("./index.php"); $fp = fopen("./skyscrapers.csv", "r"); $template = wire('templates')->get("skyscraper"); $parent = wire('pages')->get("/skyscrapers/"); while(($data = fgetcsv($fp)) !== FALSE) { // create the page and set template and parent $skyscraper = new Page(); $skyscraper->template = $template; $skyscraper->parent = $parent; // set the skyscraper fields from the CSV list($building, $city, $height) = $data; $skyscraper->title = $building; $skyscraper->city = $city; $skyscraper->height = $height; // set the URL name, i.e. Sears Tower becomes "sears-tower" automatically $skyscraper->name = $building; // save the skyscraper $skyscraper->save(); echo "Created skyscraper: {$skyscraper->url}\n"; } To do the import, make the script executable and then run it from the command line: chmod +x .import_skyscrapers.sh ./import_skyscrapers.sh OR, if you are doing this from a template file, then load the page (that is using this template) in your web browser, and that will execute it. The output should be: Created skyscraper: /skyscrapers/sears-tower/ Created skyscraper: /skyscrapers/john-hancock-tower/ Created skyscraper: /skyscrapers/empire-state-building/ Created skyscraper: /skyscrapers/ibm-building/ Created skyscraper: /skyscrapers/westin-peachtree/ If you go into the ProcessWire admin, you should see your skyscrapers. I used an example of CSV file for simplicity, but the same method applies regardless of where you are pulling the data from (web service feeds, etc). For the actual skyscrapers demo site, I used Freebase's web services feed to pull the data and images, etc.1 point
-
Launched just a few days ago: http://yummimami.de - a presentational website for a German startup supplying healthy and kid-compatible presented food to schools. Some features Responsive Forms via FormBuilder Navigation via MarkupSimpleNavigation (which, at least in my use case, evolves into something super essential for PW - like Views for Drupal for example ) Widget handling via having a big pool with pages of template type "widget", then referencing (and hence, rendering) them on content pages Editorial influence on the homepage teasers main color via SVG + field + ColorPicker (not necessary to that extent since the customer doesn't need to change the color to any other that magenta, green or brown - but still: proof of concept)1 point
-
What Martijn said!! And sshaw has also given you some great advice, and a great list from teppo. As mentioned above, you will learn everything you need to know about Processwire from the API documentation, and from posting on the forums here. We're a friendly bunch That said, it never hurts to learn some PHP, and it will stand you in good stead in PW and beyond, when you want to extend and expand things. Lots of good resources posted here, here's one more: http://devzone.zend.com/6/php-101-php-for-the-absolute-beginner/1 point
-
1 point
-
1 point
-
Naming convention: +1! Quality == new setting ? It was there since my very first day here. So, please call me youngster. Naming convention needs to respect cropped versions too => look here1 point
-
It may a good one to add a naming convention for quality 500x0-70? The quality setting is relatively new.1 point
-
1 point
-
I managed to fix a number of issues with one of my MODx sites (that jump started the search for alternatives in the first place) so my immediate crisis is over. I have checked out a couple of tutorials and watched several videos on PW. I really like what I see. I think the next step for me is to build a test site and just get in there and make the pieces fit. Some of the threads on this forum that focus on moving from MODx to PW are really helpful... Thanks to all!1 point
-
1 point
-
In case of checkbox, by default behaviour unchecked is NOT saved in DB, that's not a bug but a feature. No need to store a value, this is to either keep the logic of checkboxes and not waste space in DB. This only is an issue if you want to make the checkbox checked by default, even if you won't find any checked checkboxse by default in PW. Because it a better pattern to most of the time to inverse the logik and check a box to disable something, not the other way around. But for this case of still wanting to do the default 1, you can set the checked and unchecked value to make sure unchecked is a value that is saved.1 point
-
Well then, ensure that the Language Support - Fields Module is installed. Then, go to Setup -> Fields -> Body and change the type from Textarea to Textarea Language. That should make the field so you can edit it, but without TinyMCE working. I don't have the most experience with the Language Support stuff so maybe someone else can chime in.1 point
-
I believe the WYSIWYG Raymond is referring to is installed as a module that Processwire installs by default. It is the TinyMCE rich text editor. Do you have "debug" set to true in your config file?. Also, I'd check to see if the TinyMCE module is listed as installed in your "Modules" tab in the admin page. Like Raymond said, a missing file during install could do that, happened to me before.1 point
-
I've found the issue If you predefine a default value of (int) 1 the value is not saved to the database. ( fields.data ) If you predefine a value of (int) 0, it all works as expected. Bug is reported to github.1 point
-
Isn't that the normal practice globally? Also, define details? Some choose to send passwords and user names. Others just send user names and ask user to confirm their email address, blah blah... Spammers can be people or bots. If the former, you decide whether you check uniqueness by email or other method...As for the latter, search forums (or the internet) for "honeypot" in relation to forms ....there's other stuff out there too to help with spammers, some less effective (and/or more annoying!) than others.. Take your pick from these...http://processwire.com/api/variables/sanitizer/ . If nothing suits you there, you can roll your own Regex. You could should also start with client-side validation with some jQuery magic; no need allowing a user to submit a form with an invalid user name (or any other invalid input). BUT THIS IS no replacement for server-side validation! You must do that, e.g using your PHP and/or PW API stuff - e.g. $sanitizer....1 point
-
And just because I am procrastinating, if the role doesn't already exit: $newrole = new Role(); $newrole->name= 'frontend-editor'; $newrole->addPermission('guest'); $newrole->addPermission('editor'); //or whatever permissions you need it to have $newrole->save(); $u->addRole('frontend-editor'); $u->save();1 point
-
Help setting up a way to ask for a credit card first, then process the card for the payment, then post the page. This is probably the trickier one. I have no idea about credit card processing but there have been posts in the forums about processing payments, e.g. using paypal...Others can chip (no pun intended!) in here... I have re-read your post and see payment will be made via paypal. From what I have read in the forums (and I agree with that approach), if you can avoid it, do not handle, take or store credit card details on your site. There are "cheaper" payment gateways that can handle that for you....or redirect users to paypal. Let them deal with the security issues. Anyway, I don't know much about this area so search and/or wait for other responses Help redirecting the user to the newly created page after they have submitted the data through the form builder form. The potential issue with this is when two or more pages have been created at the same time. Creating a page via API is easy though. Redirecting is also easy: $session->redirect($url). I don't know how you are creating your pages but one way to grab the page created by "this particular visitor" is: You could get the sanitized name of the page and save that to a variable as you save the page. If the name has not been rejected, then use that name and the template of that page to grab the newly created page and use that as the $url variable in the $session method..e.g. something like....$pages->get("name=$name, template=my-template"); where $name is the sanitized value you saved in this variable before you saved the page [but only proceed with redirecting the user to the new page if one was actually created! So, you will have to check for a page id. If no id exist, the page was not created and you need to tell the user that]. You don't want to use title to get the new page since titles don't have to be unique. There could be other ways of doing it (using cookies and all that...) but the above is probably simpler...Others here will have better ideas ;-) Automatically create a user and password and assign it to the newly created page. I am not sure about creating a password. Why not ask the user to create their own password when registering? Then, save the page but as unpublished which you will then publish after you receive payment. In this case, there is no need to redirect the user to their newly created page. It is of no use to them anyway until they have made a payment they won't be able to log in. So, I would take them to a "thank you" page, awaiting confirmation and payment, blah blah message.... Creating a user is easy. Have a look at the API docs: http://processwire.com/api/variables/user/ Just my 2p1 point
-
1 point
-
Ah sorry for the misinforming, ok it's the value is returned by the formatValue so you grab it via $event->return. This should work: wire()->addHookAfter("FieldtypeText::formatValue", null, function($event){ $value = $event->return; $value = str_replace(array("<p>","</p>"), "", $value); $event->return = $value; });1 point
-
Ahm, so just missed that also with my earlier posts, it's that formatValue() or format() in Textformatters arent really hookable as it stands now. What you would instead do is hook into the text fields and hook into formatValue(), which is where textformatters are run when output formatting is on. Those are hookable in the system as they contain ___. So it would look like this instead of hooking a textformatter: $this->addHookAfter("FieldtypeText::formatValue", $this, "hookTextFormating"); public function hookTextFormatting($event){ $field = $event->arguments("field"); $value = $event->arguments("value"); .... } Or in a template wire()->addHookAfter("FieldtypeText::formatValue", null, "hookTextFormating"); function hookTextFormating($event){ $field = $event->arguments("field"); $value = $event->arguments("value"); .... } So after all coming this route, it doesn't matter if a Textformatter uses format() or formatValue().1 point
-
I don't really get the reason why not? There must be a reason why you restrain from adding the second Textformatter that does exactly what you want? foreach($fields->find("type=FieldtypeText") as $f) { $f->textformatters = array("TextformatterTextile", "TextformatterPstripper"); // add textformatters $f->save(); } Done. Not sure why your hook isn't working. You mentioned that you modified the textile formatter, how and where? Make sure it is really called TextformatterTextile.1 point
-
Whenever someone asks me about the level of PHP needed to work with PW, I usually tell them that my PHP knowledge roughly matches the ability to speak English of a 2-year old chimpanzee. Which is kind of accurate. Like you, I never managed to grasp the fundamental concepts of programming. There is a certain point to which I get it (if conditions, foreach loops, the easy things), but after that I just don't understand it. I'm constantly amazed by the ideas people in this forum come up with to solve template issues. It's been the same with Javascript back in the day when AJAX was still very new and everyone was jumping on the JS wagon. Then jQuery came along and suddenly, writing JS code became a lot easier. This is where the PW API comes in – it's been designed to work for PHP like jQuery does for JS. And it does. I still can't write a contact form script in pure PHP. Well, maybe I could, but it either wouldn't work or be very insecure. And yet, I find myself writing PHP templates using the PW API and actually having fun doing it.1 point
-
In your site config.php... Remove localhost from the array here $config->httpHosts But add yours like so... $config->httpHosts = array('domain.com', 'www.domain.com'); //Replace domain.com with the hostname(s) your site runs from. This is a new recommended security feature in PW2.41 point
-
Think of how much better it would be if I added a WillyC beard. Also, that is what happens after 2 weeks in the recording studio.1 point
-
PageImage Manipulator - Tips & Examples * how to create a PNG with transparency for the watermarkLogo method If you can use adobe photoshop, you simply may download and install this action: photoshop_action_PW-png-creations.zip create an empty image (transparent, not white or black) of 2000 x 2000 pixel write / paste your text and / or logo in a single color, (e.g. black) when finished with your text you should have one single layer with text on transparent background then click the action PW-png-creations -> 2000px-square-to-smooth and you are done. Hhm, maybe before saving you want to tweak the global transparency of the image a bit. That one used in the ProcessWire example was set to 75% instead of 100%. Just try out what looks best for you. ------------------------------------------------------------------- * did you know that you can save to different file formats, regardless of source format? You only have to specify your desired format (gif, jpg, png) with the optionally options array with a key named outputFormat and pass it with your call to pimLoad() or use setOptions() before any other action-method: // assuming the first image is a jpeg $img = $page->images->first(); // define outputFormat $options = array('outputFormat'=>'png'); // apply it together with other actions $myPng = $img->pimLoad('myPrefix')->setOptions($options)->width(240)->pimSave(); //------------------------------------------------------------------------------------------ // you may also do it as a OneLiner only with the image format conversion $myPng = $page->images->eq(0)->pimLoad('myPrefix', array('outputFormat'=>'png'))->pimSave(); // or you can use the setOutputFormat method $myPng = $page->images->first()->pimLoad('myPrefix')->setOutputFormat('png')->pimSave(); ------------------------------------------------------------------- * (how) can I use the ImageManipulator with other imagefiles than PW-Pageimages? You can load any imagefile from your servers filesystem into the ImageManipulator with: $pim = wire('modules')->get('PageImageManipulator')->imLoad($imageFilename); // or $pim = $wire->modules->get('PageImageManipulator')->imLoad($imageFilename, $options); You can directly with the imLoad-method pass specific $options or you can do a separate call to setOptions(). Then you do your desired actions and last but not least you call save()! Most time I think the original passed file gets overwritten with the manipulation result, but you are also able to save to a different name and / or fileformat. If so, it is useful to get the final (sanitized) filename back after saveing. $optionalNewFilename = $pim->setOptions($options)->height(360)->flip()->blur()->save(); Also you may call this in one line if you prefer: if(false!==$wire->modules->get('PageImageManipulator')->imLoad($imageFilename,$options)->height(360)->flip()->blur()->save()) { // success !! } ------------------------------------------------------------------- * how can I use the PageImageManipulator with my own module/s? If you build a module that do some image manipulation you can define the PIM as needed dependency in your ModulesInfo method with the key 'requires'. You may also force to install the PIM if it isn't already with the key 'installs': public static function getModuleInfo() { return array( // ... 'requires' => array('PageImageManipulator'), 'installs' => 'PageImageManipulator', // ... ); } detailed infos are here: http://processwire.com/talk/topic/778-module-dependencies/ additionally, if you need to check if a module dependency has a minimum version number, you can do it in your install method like this: public function ___install() { // check that at least the minimum version number is installed $needed = '0.0.3'; $a = wire('modules')->get('PageImageManipulator')->getModuleInfo(); $actual = preg_replace('/(\d)(?=\d)/', '$1.', str_pad("{$a['version']}", 3, "0", STR_PAD_LEFT)); if(version_compare($actual, $needed, '<')) { throw new WireException(sprintf($this->_(__CLASS__ . " requires PageImageManipulator %s or newer. Please update."), $needed)); return; } // ... more code } ------------------------------------------------------------------- * global options in site/config.php You can create a config-array in your site/config.php. If you look into it you will find a config array for the ImageSizer that comes with the PW core $config->imageSizerOptions = array( 'autoRotation' => true, 'sharpening' => 'soft', 'upscaling' => true, 'cropping' => true, 'quality' => 90 ); You can define another array with these keys: $config->imageManipulatorOptions = array( 'autoRotation' => true, 'sharpening' => 'soft', 'upscaling' => false, 'cropping' => true, 'quality' => 90, 'bgcolor' => array(255,255,255,0), ); You don't have to specify all of the options. PiM reads the imageSizerOptions and merge them with the imageManipulatorOptions. So if you want to have different values you can specify them in imageManipulatorOptions to override those from imageSizerOptions. Only one option isn't present with the imageSizer: bgcolor. This is only used by the imageManipulator. ------------------------------------------------------------------- * using PiM together with the awesome Thumbnails Module (http://mods.pw/1b) If you use the Thumbnails Module together with PiM, you can set two options in the site/config.php under imageManipulatorOptions: $config->imageManipulatorOptions = array( // ... 'thumbnailColorizeCustom' => array(40,-35,0), 'thumbnailCoordsPermanent' => true ); For the colorize dropdown select you can define the custom color here and with the second param you enable/disable permanent storage of RectangleCoords and params. The coords and params are stored with Thumbnails Module per session, but are lost after the session is closed. If you enable permanent storage these data is written into a custom IPTC field of the original imagefile. ------------------------------------------------------------------- * some more examples will folow here . . . -------------------------------------------------------------------1 point
-
Hi onjegolders, Can you tell us what exactly doesn't work? I'm not sure but I think it should be possible Have you tried $session->redirect('./') instead of ->redirect('../'); A few suggestions to the code: <input type='text' name='first_name' value='{$input->post->first_name}'> If the user submitted a value with quotes or other html signs, this will brake your form. You should escape the post vars: $v = $sanitizer->entities($input->post->first_name); <input type='text' name='first_name' value='{$v}'> To check if a user name already exists, this might be a better way than query all the users: $username = $sanitizer->pageName($input->post->username); $u = $users->get($username); if ($u->id) $message = "Sorry, that username is already taken..."; Cheers1 point