Best Practice creating Forms in Wordpress - forms

I was wondering what is the best practice for creating forms in Wordpress? As a developer I hesitate to use a plugin like CForms, but I can understand why someone would like to use it. In the end I want to know the following:
What is the best practice for creating forms in Wordpress? (Custom HTML/CSS with Javascript and PHP validation or just using a specific aspect of the Wordpress API?)

I don't use any part of the WordPress API for forms. You could automatically grab the name and e-mail address out of the cookie WordPress creates when someone leaves a comment, if you want to try to auto-populate some fields.
An easy way to handle forms is to use Page Templates. That lets you create a new PHP file for a specific page, overriding the default page template of the theme. Then you can simply have the form post to itself and this one page template handles the processing as well.
http://codex.wordpress.org/Pages#Page_Templates

A lot of what's available for WordPress in the way of addins, and what gets a lot of attention, is stuff that I find makes little use if you have programming and general web skills. Almost always they seem to (necessarily) overgeneralize a requirement with a zillion options and configuration requirements because they are first of all designed for non- or barely-programmers.
Just learn the fundamental paradigms, scratch your head and wonder why nothing is consistently abstracted and/or encapsulated, get over it, and use what you already know about php and HTML-based forms. WordPress doesn't add much in the way of either tools or constraints.
I find the Widget feature applies usefully to most everything these days, and Forms is a candidate. But that's my own WordPress viewing prism - YMMV.

What do you mean by "in Wordpress"? Do you just mean placing the form HTML in a Wordpress template? Or storing data collected in the Wordpress DB? If you just want to create a form on your site, there's nothing Wordpress-specific to worry about. I believe there's some special Wordpress data facilities you can use if you're creating a widget or plugin or whatever they're called now. But if you're not, just create the HTML, and point it at a target URL that processes the values and puts them in a DB, Wordpress or otherwise. That target URL could be a separate PHP resource, or the same page. If it's the same page, you just need to include your PHP somewhere in the main Wordpress flow.

Related

Can modifying shopify theme markup break core functions?

I'm about to take on my first shopify project where I will need to modify certain theme markup (for WCAG accessibility purposes).
Having never worked on Shopify before, I'm reading their documentation and theme editing using liquid seems fairly straightforward. However, someone warned me that modifying theme markup can sometimes break core functionality like the checkout process or something similar if/when shopify requires a certain specific markup to be present.
This would force me to opt for DOM manipulation with Javascript, instead of modifying template files - which is not a great way to go about it in my opinion.
Out-of-the box, do shopify functions depend on the markup in any way? I suppose anything's that written in Ruby should not be affected. Perhaps there would be JS that expects a specific DOM interaction. If anyone has run into similar issues, or can make any constructive suggestions, I would really appreciate it.
You can't break any Back-end functionality of Shopify if you modify the markup.
The purpose of the liquid is only to output some content, it can't modify the back-end in any way or form.
You can say that it's a glorified HTML markup with a few bells and whistles. ( but it loads before the DOM is ready )
In addition you don't have access to the checkout template if you are not on a Shopify Plus account, so it's really hard to even try to break something there.
That said you can break some base front-end functionality if you delete some items.
For example the product form needs to have an form element with an name="id" and value of the variant.id. If you remove that the product will not submit to the cart and you won't be able to use the checkout since you will never be able to add the product to the cart.
So yes you can break front-end functionality but you can't NEVER break the back-end logic with Liquid only.

Any wordpress form building plugin for my requirements?

I'm looking for a WP plugin which can allow me to create different forms and embed them on pages and following are the requirements:
Only a single textbox required in each of those forms
The submit button will only be shown if a custom entry/answer is inputted into the textbox. (basically a client-side validation)
The submitted answer should be stored in the back-end with the usermeta (or just the username of the user logged in) so that I can export the entries in a format like csv, etc.
Any thoughts?
P.S. I have found one but not sure if the PRO version of this allows me to have a validation for a custom text. This is the plugin: http://wordpress.org/extend/plugins/visual-form-builder/
Gravity Forms is the most robust form builder plugin for WordPress. You can, with the right knowledge and skills, make it do pretty much anything you'd like. You can find it here: Gravity Forms.
Very well, I've found this. There are actually good plugins however, you will have to purchase it. I'm looking for a free one. http://www.webdesignboom.com/2013/formcraft-wordpress-form-builder/

Best alternative to drupal for small-scale sites

I recently started learning about drupal integration and because I wanted to learn how to create sites that I give to people with no html experience who want to be able to update their site. Through my research I learned that Drupal is the best supported CMS. It really does have a lot of nice features and accomplishes the job, but it almost has too many features for what I want.
I'm assuming there is some kind of open-source software for
I am an aspiring web developer trying to build my portfolio/gain experience. What I've been trying to do is build sites for clients that I can lose complete contact with--so when their store hours change and they have no HTML experience, I get emails about updating their site.
I figure there are three approaches: (tell me if there are more)
I write a php app that allows them to edit their site
I use a CMS (Drupal) to let them edit their site
I write scripts that embed text files formatted with {white-space: pre;}
I've so far implemented each method on 3 different sites, and they all work with drawbacks. I would prefer an open-source alternative to writing my own app for stability/security. Drupal seems more oriented towards allowing multiple users to add content, whereas I only want one user update existing content. The third option works well for computer-literate clients, but anyone who can navigate onto their server to change the file could probably figure out how to update the site without any of these approaches.
To sum up my problem, can anyone tell me the term I am looking for? Content Management System refers to the site framework for sites with a growing number of content posts (correct me if I'm wrong). What is the term for the site framework for editing sites with predefined but editable pages? If you could please tell me that, then I can at least research this question on my own. Otherwise, if you have any advice or solutions, they are much appreciated!
Thanks
user1470887, you've asked a great question. The answer, unfortunately, is that too many of the existing CMS products overlook this use case. It doesn't have an exact name as far as I know.
The term "in-place editing" describes one version of this (user clicks text on web page, block of text becomes a form, user edits contents and presses submit button, new text is sent to webserver and saved, and the form becomes normal text again). But I gather you would be happy with anything that lets them edit-existing but not create-new.
I'm also guessing you don't want to build your own Drupal module or commission one.
I do not know Drupal well enough to know whether there's a Drupal module that meets your needs. I'd recommend a careful search, though, especially if you are already somewhat familiar with Drupal. (Yes, Drupal can seem like too much CMS at times.)
However ... if you can't find a Drupal solution or want an alternative to Drupal, MODX Revolution does have an answer: set it up and then install Bob Ray's NewsPublisher add-on. It will put an "edit" button on pages which a user has the right to edit, but not on pages where they don't have edit rights. (And of course users will only be able to edit the title, body content etc - not the entire page.)
Bob Ray has literally written the book on MODX (MODX: The Official Guide). I was able to successfully adapt NewsPublisher to a project last year similar to what you have described, with predefined pages that the user would only need to edit over time. The latest NewsPublisher version, untested by me, is said to be further improved and can now be styled much more easily using CSS. That should allow you to give your users a customised and consistent interface.
As andmag also notes, MODX is a very flexible system for web developers focused on the presentation layer. It has the best templating system going.
I'll recomend you to try MODX. It gives you big flexibility to run your php or html code.

What separates a content management system from just a bunch of web pages?

I have a website that has related pages. They have links that point back and forth to one another but I have no integrated system, nor do I know what that would mean.
What is the minimum code that a group of web pages must have to be considered a Content Management System (CMS). Is it that all the settings are in the database and the pages are generated somehow? Is there some small snippet that all my pages could share that makes them a CMS, database or not?
Thanks. I was also hoping not to have to study a giant CMS to see what makes it a CMS . After maybe a basic understanding I would know what I was looking for.
edit: here's why I ask about code. Whenever I have looked at a CMS, and maybe they aren't all the same, I saw that to develop a module you always had to inherit from certain classes and had some necessary code. I didn't know if there was some magic model that I just don't get that all cms makers understand.
edit: perhaps my question is more about being extendable or pluggable. What would a minimum look like? Is it possible to show that here?
edit: how about this? Is something a CMS if it is not extendable and/or pluggable?
I think this is really impossible to say. We all manage content. The "system" is just whatever mechanism you use to do so(dragging and dropping in Explorer or committing content changes via a SQL query). To say there is a minimum amount of code needed really isn't indicative. What is indicative is how often you find yourself making mistakes and how easy it is for a given user of a given skill level and knowledge to execute the functions in the designed system. That tells you the quality/degree of what you have in place being worthy of being called a "CMS."
Simply put a CMS is an application that allows the user to publish and edit existing web content.
In response to the edit:
A "good" CMS allows of extensibility. By using inheritence you can extend the functionality of a CMS outside of the core components provided. That's the magic.
About Extensibility:
Depending on the language/framework you want to build your CMS with, you can load pages or controls(ASP.NET) using command built into the framework. Typically what is being done is a parent class/interface is being defined that forces an module that is to be developed to follow some given standards:
Public MustInherit Class CMSModule
'Here you will define properties and functions that need to be global to all modules being developed to extend your CMS.
public property ModuleName as string
End Class
public class PlugInFooCMSPage
inherits CMSModule
end class
Then it's just a matter of simply loading a module dynamically in whatever construct a given language/framework provides.
Ultimately, a CMS is a system that lets you manage content, so it needs an user interface that is dedicated to letting you easily create, edit and delete pages on your website.
However, it's fairly usual to expect from a CMS to provide a browser-based WYSIWYG page editor, file uploading, image resizing, url rewriting, page categories and tags, user accounts (editor, moderator, administrator), and some kind of templae system.
Without dragging you into a theoretical explanation of what a CMS is and what it's not, perhaps some tutorials on the building methodology of a CMS will help you better understand.
http://css-tricks.com/php-for-beginners-building-your-first-simple-cms/
http://www.intranetjournal.com/php-cms/
A Content Management System is a System that Manages Content. :)
So if you got many pages that share the same layout, you can create a system that stores the content into a database and when a page is requested, it gets that content, merges it with a template that contains the page header, menu, etc.. and outputs the result.
The basis idea is that you don't want to copy HTML pages, and have to edit hundreds of them when you want to change your layout.
Such a system can be very complex, featuring wysiwyg editors, toolbars, version control, multiple user publishing and much more, but it could be as simple as a single page behind a standard loging, that contains only an input field for the title and a textarea in which you type the html content.

What is the most difficult part in converting a static website to a dynamic website?

Consider I am having a website with 5 to 10 static information pages and there is no database. How difficult will it be to convert it to a dynamic website with userlogin and interaction, typically a cms? Do you have an easiest method to do the same?
The easiest way is to use some open source software and stick with the out-of-the-box functionality, possibly using a readily available (free) template.
Look into Joomla, Wordpress (Blog software, but works, too), Drupal (a little more complicated), SilverStripe, ....
Totally depends on what type of dynamic pages you want to create. If it's just plain cms like functionality it won't be a hell lot of work. Just convert the text into fields in a database.
You could think of just going for an cms and copy / paste your content into it and style the pages using css. It might be easier then building a cms that you can just get anywhere on the internet nowadays.
Joomla - CMSmadesimple etc. can be nice to look #