I need help wrapping my head around how to complete a system in Silverstripe.
There is a page where an authorized user can manage archives. This is NOT in the cms. It is a front end system.
I need to be able to walk the user through creating the following:
1. Archive (it has a year and title)
2. every archive can have many sections with (title, description)
3. every section can have many items with (photo, description)
I can create the three dataObjects but I can not figure out how to:
1. relate them using $many_many or $has_many
2. create a form for each step so the user can add the three different pieces.
This would be easy in straight PHP/MySql but Silverstripe is new to me. I don't need the code per se, just an explanation of how the pieces work together to get what I want. The docs and forums are scarce on silverstripe.org
In order to understand the data model it is best to complete the lessons / read the documentation.
http://www.silverstripe.org/learn/lessons
https://docs.silverstripe.org/en/3.3/developer_guides/model/
http://www.silverstrip.es/blog/diagram-of-relationships-in-silverstripe/
As for the multi page form this module...
https://github.com/silverstripe/silverstripe-multiform
... is perfect for you as it manages multiple forms and temporarily stores all the data, allowing the user to go backwards and forwards through the steps, and only at the last step when all is confirmed is all the temporary data actually processed with one function to create the required objects and relationships.
This module has a fantastic README.md on github and guides you through creating a form very well.
Related
I'm having difficulties implementing some of the features my client would like to have.
We're building a shopware shop, which is almost done. I've developed some plugins and customizations to have the shop fit my client, but I'm not the best at backend development using ExtJS and Doctrine.
The situation is: The shop sells car parts. We've bought a third-party plugin that allows us to enter ktype numbers for each product, so that the client can search for his/her car in the frontend and get all fitting products.
The plugin has it's own window in the backend, which isn't very comfortable.
So I created an extra tab in the article details, which displays all entries from the database using the third-party model.
That wasn't so hard since the model and database were created by the third-party plugin and I just had to query the data and display it.
What I'm trying to accomplish is: I added an extra column (selected) with a checkbox, where the admin can choose the cars the article fits to.
The plan was to read the textfield "ktypes" of the article on load, check all corresponding checkboxes and then when a checkbox is altered just save the new ktypes array to the article.
Problem is, that this way I can't sort by that column since it's not in the ExtJS store/model.
So now I'm thinking I'll create my own Model with all the columns from the third-party model, add a article_id column and a selected column and reference everything there.
What I don't know is: How to I get the contents of the third-party model into my own database?
The third-party plugin doesn't reference the article. The table only holds all car data imported from a csv list. The reference between an article and the data is just a textfield in the article details.
I thought about Doctrine associations, but I don't really have a reference point or foreign key...
Has anyone got an idea how to solve this?
Can share code if that helps...
Thanks!
I went in a different direction but still need help. Will post a new question though since it's a different topic.
Thanks for trying to help!
I am developing web application, using zend framework 2. In my app, I want some modules. News, for example, users etc.
Is it possible, to divide whole application to two big parts: front-end (for users) and back-end (for admins).
In front-end there will be part of News module, which render news list, full news item etc.
In back-end there will be part of News module, which will render list of all news, tools for editing, deleting etc.
At the moment, I have simple structure:
I have MyZfcAdmin module, with routes configurated so, that when I am writing /admin/news/edit/5 it will call NewsController edit action with id 5 and render it. So now, I have all actions (for admins and for users) in one controller. Is it possible to create something like this:
module
frontend
News
SomeMoreModule
backend
News
SomeMoreModule
I found topic on google questions, in that suggested to use this CMS, but I want to try it by myself.
Different people have different idea in managing application, for me I will have news module that handle all news related calls both admin parts and user accessible parts. The idea you have described have some side effects like duplication of code between modules and crossing of borders between isolate modules like calling action in another modules(it's ok if there are related or fall in hierarchy), which may have issues in long term maintenance of the applications.
IMHO I might suggest you could create modules like News, users, etc where it can have combined functionality of both admin and user access. You can later include user authorization plug ins using bootstrap events and restrict action accessible by admin and other users
There is not concept of submodules inside any module. But you can give them proper naming conversations. If code is not formed in oops properly, then there can be code duplication into your project. As per #raj's answer, it's good to give restrictions based on user role. If any action is not intersecting admin and user role then you can separate those actions, but actions like add or edit news content are same for both role then you should point to same action by router.
A noob here (2-month old, literally, Drupal-PHP user)
What I am trying to accomplish:
1.1. A map that shows multiple locations as the user chooses them.
Therefore, the map can show 0-100+ of locations depending on the choice/selections that user makes
These locations will be under 1 (one) content_type (ie: business) each with unique NID
On the other word, the business location markers should be toggle on and off, individually (keeping the previous locations choices)
1.2. On the same map, the user can then choose one (or multiple) bus routes. When user chooses different bus route, the location markers (from #1.1 above) will stay on the map
Bus routes will be under another content_type with their own NID
What I had done so far:
2.1. Using OpenLayers module to create the map
2.2. Using Views module to display the map, setting up contextual filter so it can show multiple markers (reqd #1.1)
2.3. Using Views module to display the list of business locations, rewriting the outputs to it point to the URL of the view from #2.2 above
What I still CAN NOT do:
3.1. Creating a view where the list of the business locations are in the form of checkboxes, so the user can choose which locations to show (ideally it should be AJAX-y so the user does not need to press the submit button, but the map marker will toggle on-off as user checks and unchecks the location)
3.2. After #3.1 above is accomplished, do the same thing with the bus route
What I had tried so far:
4.1. Installing couple of View-helper modules, like BEF, VBO, and such
4.2. Try to create a theme the view jumpdown style plugin --> utterly fail as I do not know enough Drupal nor PHP
Can not get this to work: http://www.civicactions.com/blog/2011/apr/15/filtering_a_view_by_a_list_...
Please help:
5.1. to educate me how to create a custom Views Style Plugin (creating checkboxes)
5.2. how to pass the values (NIDs) of the checkboxes to the URL (contextual filter) dynamically
Will it be helpful if I give you the URL of the page I am trying to develop?
I am also open to use different Mapping module if that one has the feature I need
Thank you in advance,
PS: have posted this on the Drupal forum, got no answer so far
Hopefully, this link will help me convey what I am trying to do:
http://link2.cswebdevelopers.com/map-of-lm_locations
On the page above, I can choose ONE location at the time and the map will show a yellow marker. I am using Views 3 and OpenLayer modules
What I would like to do is to have the dropdown or the unordered list on the left sidebar become CHECKBOXES so the user can check and uncheck 1 or more locations and the map will show 1 or multiple markers as appropriate.
Thank you
I am building a very simple website ( http://driz.co.uk/beta/ ) using CakePHP to show a portfolio of my work as well a few pages such as about me and contact. I was thinking of just creating each item for my portfolio as a page inside the /views/pages/ folder but seen as I'm wanting to learn a bit about CakePHP I thought it would be probably better to use a database and store each item in a simple table.
What I need to do is have a simple page like /portfolio/ which lists all my work to date and then links to each item I have so for example /portfolio/my-awesome-work/
I also need to list the items in the sidebar as shown in the link.
For each portfolio item I will need a title, a body (which will store the content and images for each item) and also the client information. I don't need any image upload capabilities as I will be just adding the HTML for it in the database table.
If anyone can help it'd be much appreciated.
Thanks
Hopefully you aren't asking for a full solution (frowned upon on SO)
First follow the blog tutorial : http://book.cakephp.org/view/1528/Blog
This is a great place to start as it walks you through all the basics.
As for your particular problem. Creating a portfolios table with all the fields you mentioned and baking the code (you'll know what that means when you follow the tutorial) as a starting point will get you half way there.
You could also add in an admin area to manage your system. This would mean you'd need to create a users table and add the Auth component
I am using Symfony 1.2.9 (with Propel ORM) to create a website. I have started using the admin generator to implement the admin functionality.
I have come accross a slight 'problem' however. My models are related (e.g. one table may have several 1:N relations and N:N relations). I have not found a way to address this satisfactorily yet. As a tactical solution (for list views), I have decided to simply show the parent object, and then add interactions to show the related objects.
I'll use a Blog model to illustrate this.
Here are the relationships for a blog model:
N:M relationship with Blogroll (models a blog roll)
1:N relationship with Blogpost (models a post submitted to a blog)
I had originally intended on displaying the (paged) blogpost list for a blog,, when it was selected, using AJAX, but I am struggling enough with the admin generator as it is, so I have shelved that idea - unless someone is kind enough to shed some light on how to do this.
Instead, what I am now doing (as a tactical/interim soln), is I have added interactions to the list view which allow a user to:
View a list of the blog roll for the
blog on that row
View a list of the posts for the blog on that row
Add a post for the blog on tha row
In all of the above, I have written actions that will basically forward the request to the approriate action (admin generated). However, I need to pass some parameters (like the blog id etc), so that the correct blog roll or blog post list etc is returned.
I am sure there is a better way of doing what I want to do, but in case there isn't here are my questions:
How may I obtain the object that relates to a specific row (of the
clicked link) in the list view (e.g. the blog object in this example)
Once I have the object, I may choose to extract various fields: id etc.
How can I pass these arguments to the admin generated action ?
Regarding the second question, my guess is that this may be the way to do it (I may be wrong)
public function executeMyAddedBlogRollInteractionLink(sfWebRequest $request)
{
// get the object *somehow* (I'm guessing this may work)
$object = $this->getRoute()->getObject();
// retrieve the required parameters from the object, and build a query string
$query_str=$object->getId();
//forward the request to the generated code (action to display blogroll list in this case)
$this->forward('backendmodulename',"getblogrolllistaction?params=$query_string");
}
This feels like a bit of a hack, but I'm not sure how else to go about it. I'm also not to keen on sending params (which may include user_id etc via a GET, even a POST is not that much safer, since it is fairly sraightforward to see what requests a browser is making). if there is a better way than what I suggest above to implement this kind of administration that is required for objects with 1 or more M:N relationships, I will be very glad to hear the "recommended" way of going about it.
I remember reading about marking certain actions as internal. i.e. callable from only within the app. I wonder if that would be useful in this instance?
I'm assuming your application is called backend. Suppose there are two models, BlogPost and BlogPostComment. These are managed using admin generated modules called blog_post and blog_post_comment.
I believe you want a link against each BlogPost displayed on the list page at backend.php/blog_post. The links take you to backend.php/blog_post_comment, which should only show comments related to the relevant BlogPost.
Under apps/backend/blog_post/templates, create a file called _commentslink.php and put this in it:
View Comments
Then in apps/backend/blog_post/config/generator.yml, you need to include this partial in the fields for the list view:
....
param:
config:
list:
display: [ id, title, _commentslink ]
Note the _commentslink - the _ tells it to use a partial instead of looking for the field in the model. Your object is available in this partial as $<name of model> - $blog_post in this case.
Essentially, all this method does is links to the same action as the filter on the comments list normally goes to, passing the relevant condition to it to make it filter by blogpost_id.
If you've got CSRF protection enabled in the backend, you'll need to disable it, or this method won't work. This is set in apps/backend/config/settings.yml. There will be a setting in there called csrf_secret - it should be set to false to disable csrf.
You should try symfony 1.3/1.4 out if you need support for 1:N relationships in forms. 1.3 is in my experience a relatively hassle free upgrade from 1.2.x - 1.4 is the same, but with deprecated features removed.