Jump to content

Search the Community

Showing results for tags 'save page by template'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 1 result

  1. Hi everyone! I have managed to build a little form where the entries are saved as a page. That works nice. My problem is that I need to use several forms for several diffrent questions, while the answer to each question is going to be listed below. For assorting the answers to their related questions I have made child pages for each question and gave them different related templates. The POST page should be saved under the parent, which is one child of the question siblings, and it should be given the particular template related to the child page. (It even worked fine one time before I made some changes). The problem is that the generated page from the form is then saved under all of the question siblings as a child. Where is the problem? I have six pages with six different templates. The templates all are holding the same fields. On submit a child page, basing on the template(s) is generated but unfortunately saved as a child under all of the six question pages. I want to save each answer as a child page of the related question page, but only there. What goes wrong? I am using Ryan's proposed snippet for such task, which I am greatly thankful for. Still in development and not much changed it looks like this: <?php // form was submitted so we process the form if($input->post->submit) { // create a new Page instance $p = new Page(); // set the template and parent (required) $p->template = $templates->get("kommentare_zitat_1"); $p->parent = $pages->get("/comments/kommentare_zitat_1/"); // populate the page's fields with sanitized data // the page will sanitize it's own data, but this way no assumptions are made $p->kommentar = $sanitizer->textarea($input->post->kommentar); $p->namez = $sanitizer->text($input->post->namez); $p->profession = $sanitizer->text($input->post->profession); // PW2 requires a unique name field for pages with the same parent // make the name unique by combining the current timestamp with title $p->name = $sanitizer->pageName(time() . $p->title); $p->save(); header("Refresh:0"); } else { // no form submitted, so render the form include("./comments-form.inc"); } ?> The template "kommentare_zitat_1" also exists as "kommentare_zitat_2" etc. The parent page "/comments/kommentare_zitat_1/" has siblings until "/coments/kommentare_zitat_6/". Now any time I am submitting an answer to one question/page, six pages are saved, each question sibling gets one. Might there be an easy solution? I don't know why this is not functioning anymore. Thx, Daniel
×
×
  • Create New...