Hi, usualy we create pages in Admin Panel, but I want to allow some users (They dont have permission log in to Admin Panel) to create pages using Front End. In Admin I created pages like this "Categories/Category/CategoryPage", so how could I transfer page creation method in Front End? So users could choose Category and then add CategoryPage to it?
Maybe where are some tutorials or maybe you could explain simple way of creating just one page in Front End with title and content which would be seen in Admin Panel and also in Front End ect.: News page? That would be a start for my idea:) Hope somebody will help, thanks
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
- Page 11(current)
- 2
- Next 10 entries
Hi Johnny9,
To help guide you in the right direction, you would have to create a form and form handler function that creates a page for you based on the form input. It's important to remember that a "Page" in SilverStripe is really just a DataObject.
Form tutorial: http://doc.silverstripe.org/framework/en/tutorials/3-forms
Tutorial on Creating DataObjects from the front end: http://www.ssbits.com/tutorials/2012/s-new-post-78/ - this is an older article but should help out.
Let me know how you make out and I will assist as best I can.
Thanks IOTI. I will start by creating form and using these tutorials to build what I want. See you soon, because help will be needed :)
So, I made upload form, with title, content and ect. All posts goes to database and I successfully return whem to front end. I did all this using that first tutorial. But what should Į do, that these database entries would be displayed in admin, like pages? Thanks for any tips :)
Second tutorial is done.. But, still dont get, how to make form that could create page in admin and in front end :/
Hey Johnny
You know how to create a dataobject using a form thanks to the first tutorial I linked to. As I said earlier a page is really just a dataobject so you'll do pretty much the same thing. Your code would look something like this.
class Page_Controller extends ContentController {
public function CategoryForm(){
//Fields
$fields = new FieldList(
new TextField('CategoryPageName', 'Name')
);
//action field
$actions = new FieldList(
new FormAction('CategoryFormHandler', 'Post')
);
//required Fields
$requiredFields = new RequiredFields(
'CategoryName'
);
//creating form
$form = new Form(
$this,
'CategoryForm',
$fields,
$actions,
$requiredFields
);
return $form;
}
public function CategoryFormHandler($data,$form){
if($data['CategoryPageName']){
$page = new CategoryPage();
$page->Title = Convert::raw2sql($data['CategoryPageName']);
$page->write();
$this->redirectBack();
}else {
return $this->redirectBack();
}
}
}
This is a super basic example. You'll want to add some logic to make sure that the CategoryPageName the user entered isn't already taken.
You mentioned you also wanted the user to be able to pick a Category. You'd want to create a dynamic dropdown field that lists all of the category pages. Check out this tutorial for some tips on doing that: http://www.ssbits.com/tutorials/2010/dynamically-generating-a-dropdown-list/.
Again let me know how you make out with this and I will assist as best I can.
Thanks for help IOTI :) will try to adapt your code soon.
Yes!! It works! When you done step by step it is realy not so hard to do:) Really appreciate your help IOTI:)
Another step, I want to make, let users to choose Category (what I have done) and after they choose Category corresponding form appears.
Ect. Choose: Category A, appears Form A. Choose: Catefory B - appears Form B. I have idea how to make this, but if you know any more tips how to do this in right way, please share.
- Page 11(current)
- 2
- Next 10 entries