-
Posts
4,314 -
Joined
-
Last visited
-
Days Won
80
Everything posted by diogo
-
I don't want to complicate things, so until the above is working and understood just ignore this post. If you want the fields to match the theme of the admin, you can use the built in methods to create them. Let's adapt Soma's instructions from here http://processwire.com/talk/topic/2089-create-simple-forms-using-api/ to our example above: <?php if($input->post->submit) { $thought = new Page(); $thought->parent = $pages->get("/thoughts/"); $thought->template = "thought"; $thought->name = time(); // page name can be a timestamp, this will make it unique $thought->title = substr($input->post->thought, 0, 30); // let's make the title match the first 30 characters of the thought $thought->body = $input->post->thought; $thought->save(); // confirmation message with link to edit the new thought echo "<p>A new thought was created. Edit it <a href='{$config->urls->admin}page/edit/?id={$tweet->id}'>here</a>.<br>Create a new one?"; } //create a new form wrapper $form = $modules->get("InputfieldForm"); $form->action = "./"; $form->method = "post"; $form->attr("id+name",'new-thought'); //create a textarea input $field = $modules->get("InputfieldTextarea"); $field->label = "Thought"; $field->attr('id+name','thought'); $field->required = 0; $form->append($field); // append the field to the form //the submit button $submit = $modules->get("InputfieldSubmit"); $submit->attr("value","Submit"); $submit->attr("id+name","submit"); $form->append($submit); //render the form echo $form->render(); ?>
-
Here is an example for how to create the "thoughts pages". Let's say we have all our thoughts as child pages of a "thoughts" page, and that they will have a template name "thought". home -- one page -- another page -- thoughts ---- my first thought (template: "thought") ---- one more thought ---- ... --admin Create a "new thoughts" custom page in the admin (follow the instructions in the module), and paste this to it's template: <?php if($input->post->thought) { $thought = new Page(); $thought->parent = $pages->get("/thoughts/"); $thought->template = "thought"; $thought->name = time(); // page name can be a timestamp, this will make it unique $thought->title = substr($input->post->thought, 0, 30); // let's make the title match the first 30 characters of the thought $thought->body = $input->post->thought; $thought->save(); // confirmation message with link to edit the new thought echo "<p>A new thought was created. Edit it <a href='{$config->urls->admin}page/edit/?id={$tweet->id}'>here</a>.<br>Create a new one?"; }?> <h2>Write a new thought</h2> <form action="" method="post"> <textarea name="thought" rows="4" cols="50"></textarea><br> <input type="submit" value="Send"> </form> What version of PW are you using? Edit: thanks for the edit Pete, I forgot that detail
-
@daniel.s, this is not a good case to use repeaters as the number can grow to the point of not being practical at all. Pages is the way to go. @BeardedCanadian (great name ) the way around the two step page creation is to create a new system for making these new pages. You can easily create new pages with the API http://processwire.com/talk/topic/352-creating-pages-via-api/. So, the only thing you need is to a new page where you put a form with the needed fields for your thoughts/quotes/links and use the API to create the pages instantly. If you want these pages in the admin, have a look at my Admin Custom Pages module http://modules.processwire.com/modules/process-admin-custom-pages/. edit: and welcome to the forums both of you!
-
Just stumbled on this http://scrollback.io/. Could be a nice solution to bring the IRC channel to the forum.
-
Is there a disadvantage to adding modules to /wire?
diogo replied to bcartier's topic in Modules/Plugins
same for themes -
Ok, maybe I misread your question. There is one thing that I didn't answer. You can hide these pages from editor by putting them as children of a page under the "admin" page. They will also be hidden from searches, but if you call them like this: -admin --datapages (id:123) ----somedata ----moredata $pages->get(123)->find("selector")
-
Hi Emmanuel, its's very easy to convert data to PW if you start thinking in tree instead of table structure. Let's say json/mongo vs mySQL/excel. One important thing to have in mind is that besides the parent child structure you have also the possibility to connect the branches of the tree with page fields, which makes it very flexible. I think the best way to structure data is to convert 1 to 1 relations as parent/child connection, and 1 to many relations as page field connections. When you query the database with PW, the "pages" are stored in a pageArray object. Obviously, if you have lots of data, this will empty your memory very quickly. That's why you should always limit your queries ("limit=50") and paginate the results when needed.
-
Is there a disadvantage to adding modules to /wire?
diogo replied to bcartier's topic in Modules/Plugins
I don't think there is any disadvantage besides the upgrading. -
Only under the same parent.
-
How to not show "Previous" link on first page in array
diogo replied to webweaver's topic in Getting Started
Welcome to PW purwa! Make sure you read kongondo's new bible http://processwire.com/talk/topic/3691-tutorial-a-quick-guide-to-processwire-for-those-transitioning-from-modx/ -
32
-
You would need a script for sure for importing data. But you have to divide the task in three: 1. Build the "site theme" in processwire. This is not more than identifying all the different pages on the website, divide their html by templates and replace the dynamic parts. 2. Mirror the website structure in the PW tree. 3. import the previous content to the new site. Your site seems to follow a very simple structure (not too different from the default PW website, so you can take some ideas from there), I would say 5 templates maximum: Home, basic-page, blog, contact, site-map. Header and footer would be the same in all templates, being that home would have a subheader (very easy since that one just follows the header in the markup). basic-template would need only two fields: body and headline and and title (this is for mirroring the website as is, although with processwire you could actually make the content richer by creating more specific templates. But let's stick to mirroring the website for demonstration purpose). The structure could be something like: Home (render "Poland" page) -- Poland (headline: Poland Explorer Travel and Tourist Guide) ---- About Poland Explorer ---- How to use Poland Explorer ---- ... -- Provinces (headline: Provinces of Poland) ---- Poland Explorer Travel and Tourist Guide ---- About Poland Explorer ---- ... -- Geography (headline: Geography of Poland) ---- Map of Poland ---- Mountains of Poland ---- ... -- History (headline: History of Poland) ---- Heads of State of Poland ---- Katyn Forest Massacre ---- ... -- Other Activities ---- Aviation ---- ... -- Blog ---- Article 1 ---- Article 2 ---- ... -- Contact&Search -- Sitemap (hidden from navigation) The basic template would be something like this: <? php include('head.inc'); php include('sidebar.inc'); echo $page->headline; echo $page->body; php include('footer.inc'); Yes, that simple! sidebar.inc would be something like: <div class="column fourcol"> <?php include('search.inc'); <h4><?php echo $page->headline; ?></h4> </div> <div class="widget widget_nav_menu"> <ul id="menu-provinces-of-poland" class="menu"> <?php $children = $page->children->count ? $page->children : $page->siblings; foreach($children as $c) { echo "<li><a href='{$c->url}'>$c->highlight</></li>" } ?> </ul> </div> ...and so on. There are plenty of examples in the default site that would fit very well in practically all problems you would find. The importing part is well covered in Ryan's post that was linked above.
-
My suggestion is to use the last LTS (long term support) version of Ubuntu, right now is 12.04. The documentation in Linode is very good, follow along with their "Getting started" tutorial and you should be fine.
-
You're too nice kongondo
-
I think there's not a ready solution. What you could do to overcome your problem is actually not that complicated, and it would only add one step to the process. Instead of storing the image page on a page field, just pull the image to a image field in the "user" page and delete the other page.
-
I did this already and the method that I used was having the images on their own page instead of on the user page (images were avatars for users) and having a page field on the user page to link to the image. This was more or less the process (by memory): First Ajax call for the image creates a image page under the "images" page in the tree and returns the id of the newly created page. The returned id is stored on a hidden field with javascript and sent back to the server with the rest of the form on submission. While processing the form in the server, the previously created image page is stored in the page field of the new user page.
-
field_page=0 will return also all the pages that don't even have this field i their template. The correct way to return pages with an empty page field is field_page.count=0. Unfortunately there is no way of combining field_page.count=0 and field_page=123 in one selector, so you would have to create two different arrays, and merge them. You can do this with $a->import $myPages = $pages->find("field_page.count=0")->import($pages->find("field_page=123")); After this you will have an array with all the desired results and you can even sort it as you would in a selector: $myPages->sort("created"); Edit: Pete, i just saw your answer. I don't think that it works for page fields...
-
Release: Font Awesome Page Label (module)
diogo replied to Martijn Geerts's topic in Modules/Plugins
Well, I see two in your picture, which one is Martijn and which one is Geerts? -
I'm glad you will be sticking with us Here is the A-B-C: http://processwire.com/api/ http://processwire.com/talk/topic/693-small-project-walkthrough-planets/
-
@RIVO, I'm as surprised as you that you still keep coming back to ProcessWire. It really sound that this is not the tool you are looking for. That said, I will try to explain why PW is not as "usable" as others by listing some points. Flexibility (first and last point on the list)----- PW as a very well defined kind of user: coders (and willing to learn non coders) that look for extreme flexibility. The fact there there aren't many built in features makes it possible that (with some work, but not a lot) things will be exactly as you want them to be. It can seem a bit scary at first, but if you actually try to use the API you will understand how intuitive it is and how easy it is to come up with several ways of quickly building the features that you mentioned. Anyway, I can't say I agree with PW lacking those many basic features. Let's go through them one by one: There is a module for basic contact forms http://modules.processwire.com/modules/form-template-processor/. If this is too basic there's always Ryan's excellent form builder http://modules.processwire.com/modules/form-builder/ Really?? TinyMCE is exactly the same as in Wordpress and many other CMSs and there are plenty of instructions around the forum to extend it with buttons and plugins. If you prefer CKEditor (as I do) and are not able to install it, just ask in the forums, and I'm sure we will figure out what's happening. What do you mean? A frontend gallery? There are plenty javascript plugins for galleries. The advantage is that PW let's you easily use any of them. Here's is a tutorial on how to implement one of those (flexslider) http://wiki.processwire.com/index.php/Simple_Gallery_System. Please read http://processwire.com/api/multi-language-support/multi-language-urls/ Again, flexibility, flexibility, flexibility... PW will never touch your frontend code (plugins might do it, but not the CMS itself), you'll have to build the page yourself (use dreamweaver or an html template if needed), and in my opinion PW is by far the easiest and most flexible tool for doing it. Welcome to the forum
-
Very clever and useful. I'll use it for sure!
-
Did you change the default XAMPP credentials for mySQL? Does it work if you use these? $config->dbHost = 'localhost'; $config->dbName = 'change to your Db name'; $config->dbUser = 'root'; $config->dbPass = ''; $config->dbPort = '3306';
-
Hm, the logs don't help more than the first message. Check if your database credentials are correct on the /site/config.php file