How to implement Restful design to request webpage stored for magnolia - magnolia

I have a question concerning how to implement restful design to request webpage stored in magnolia JCR.
For example,
I have a list page called itemList [www.example.com/itemList], which contains a list of item.
And i have a item page [www.example.com/itemList/item/1], which is a child page of itemList (which can be seen in the PAGES app).
If i want to get item with ID no.1, just like other restful design, just use URL [www.example.com/itemList/item/1], and it will return whole page of item with item no.1 data (which i need to store the ID and pass it to the JAVA custom module in template script to get the data)
But here is the problem,
as i study in the magnolia documentation, like
https://documentation.magnolia-cms.com/display/DOCS57/How+to+create+a+custom+Java-based+REST+endpoint
it just tell about create rest endpoint and get the JSON data back as for manuplation.
And i got stuck at how to achieve my goal, may i have some suggestions?
Thanks a lot for any help. ORZ

Actually in Magnolia you don't need to create a custom endpoint for that, you can use the pre-defined ones which are sufficient to achieve what you want. Have a look at https://documentation.magnolia-cms.com/display/DOCS57/REST+API
Let me know if that covers what you need or any other extra questions that should you have.
Hope that helps,
Cheers,

Related

How to query data and display them in the common layout page (_layout.cshtml)?

I had tried the tutorial https://learn.microsoft.com/en-us/aspnet/core/data/ef-rp/intro?view=aspnetcore-3.1&tabs=visual-studio
And I am able to display the data with Razor pages with page model.
However, when I was trying to find ways to display a student name at the top using the common layout page, Shared_layout.cshtml, I got lost and would hope to seek your advice on how I could query for the data from the Student Entity and display just one name in the common layout page.
I felt lost because there is no page model for the common layout page.
Note: I am new to application development, so hope you could provide some guidance to enlighten me. Any good learning reference would be great as well :)
You can use ViewBag to display student name at the top.
Add ViewBag in all your action methods where you are returning view as return type from controller files.
ViewBag.StudentName = "Yiwen";
Use it in your common layout file.
#ViewBag.StudentName
You can see microsoft link on how to use ViewBag.

Silverstripe URL Mapping

I'm trying to understand how URL Mapping works. I've gone through numerous pages, but I can't seem to wrap my head around what I'm trying to do.
Its really simple, I use DataObjects as pages approach and I have a member extension written to the member class. And I have the typical actions, show, edit, add.
So if I go to www.mywebsite.com/members/show/1 I can see the first user. If I change show to edit, I can edit the first user. Now if I go to www.mywebsite.com/members/add I can create a new user. This is working all as expected due to the functionality I created in the add method.
My problem is in the fact that when you go any website, you don't register to the website by going to members/add, you register by going to website.com/Register or something similar. From code management perspective, it is a lot easier for me to leave the code the way it is now. I don't want to have to create a Register page and move the code there, instead I am trying to figure out if it is possible to go to www.mywebsite.com/Register and have it load www.mywebsite.com/members/add. I am not talking about a redirect link that would update the url, I want users to still see Register in the url and not see /members/add.
Vice versa, if users were to go to www.mywebsite.com/members/add I want the link to update to Register or say page not found.
Is this possible with Silverstripe Framework?
I am not 100% sure, but I believe this is called URL Masking.
This is very possible, firstly I'd advise that you look over...
silverstripe-memberprofiles
...because even if you dont' want to use an existing module I'm sure there would be useful information. There is a great example of "pure" routing (i.e. silverstripe no cms) that leads on to "nested" routes - which is what I think you are asking for, so I highly recommend reading the slides below and then the created todo app
silverstripe-framework-building-without-the-cms
todo app source

Displaying .Net Page within Page

So I have a .Net website I made and part of it is a page where a database table can be filtered, queried, and displayed. Then I allow users to select an individual row to either edit or delete. Both of these functions are performed on their own separate pages. Recently I was asked to add functionality to the first page to allow for the query filtering to be preserved between visits. For example, if a user edits a row then returns to the table, the filters they selected should still be in place.
My question is what's the easiest way to do this. The problem is that many of the filters are dynamically generated based on another table in the DB so they aren't statically coded into the page. One option would be passing the filter string in the query string but this seems unpractical because of the possible great length it may be. I also thought about opening a new window but there are concerns about security and data duplication. I could also use an iframe to load the pages and hide the original content until done editing but I'm not sure how to access clicks from within the iframe in the surrounding page, or if this is even a good idea.
Any help/suggestions would be greatly appreciated.
Thanks!
You could encapsulate your functionality into a User Control that both pages can use.
How to: Convert Web Forms Pages into ASP.NET User Controls
You could use a SESSION variable to store a Dictionary<string, object> or something similar which contains keys identifying each table and values representing the filter. The actual filtering options shouldn't be too much information to store for a given session.
Without knowing how your application captures the concept of a filter it's a little difficult to offer a fully-qualified solution, but session seems like a decent option.
You can keep the filter in a cookie on the user side. Granted not a perfect solution but it's one way to go.

How can I categorize the content types on the Drupal "Create content" page (/node/add)

How can I categorize/organize the content types on my "Create content" page? I'm running Drupal 6.x with CCK. I have a lot of custom content types, and my "Create content" page has become a bit unwieldy, as it lists them all alphabetically. I'd like to organize them by category, so users would see something like:
Create Content
Reports
Report Type A
Report Type B
Events
Event Type A
Event Type B
I don't want to mess with Core, but anything else (custom module, theming, existing module functionality) is fair game. I'm hoping I'm missing something easy, because this seems like an obvious requirement, but all I could find on the Drupal site were these unanswered questions:
Organize Create Content Page
(node/add)
Core: Split create
content page into categories?
You should be able to accomplish this in a custom module, without hacking core.
You'll want to implement hook_menu_alter() to take over the callback function for node/add.
Something like
function mymodule_menu_alter(&$items) {
$items['node/add']['page callback'] = 'mymodule_node_add_page';
}
should get you started. You would then create the function mymodule_node_add_page, and you could use the original callback function as a starting point.
You can also do this at the theme level by overriding theme_node_add_list().
There are some different ways to attack this problem. You can overwrite the old form page or just create a new one with a custom module. Doing that you can in your module do whatever your want.
Another possibility is to do the same thing using views instead. Doing that gives you access to a lot of powerfull features, as you can do anything the views module lets you do. You can create different ways of sorting the content types.
I've heard of many who have used views to make a page like this for the create content page. Which method you choose is up to you, depending on how exactly you want to do this and the data you have associated with your content types, one will be more easy than the other. But without knowing the exact details, I can't say which. I would advise you to start out with views, since you quickly should be able to find out, if you can use it to get what you want.
there's a module that does what you are looking for, Content type groups
I created a sandbox module some time ago which was supposed to do this:
https://drupal.org/sandbox/YaronTal/1260038
The only problem is that I wasn't able to create the admin backend with draggable interface at the time.
I know the issue is old, but just in case someone else has the same problem...

user controls and asp.net mvc

Here is one trivial question, that I am not sure how to handle.
I need to display list of categories on every page, and to be able to choose items from a specific category to be displayed. I use asp.net MVC, and have chosen to create a user control that will display categories. My question is: what is the best approach to pass data to a user control. I already found some information in these blog posts:
http://weblogs.asp.net/stephenwalther/archive/2008/08/12/asp-net-mvc-tip-31-passing-data-to-master-pages-and-user-controls.aspx
http://blog.matthidinger.com/2008/02/21/ASPNETMVCUserControlsStartToFinish.aspx
I would like also to hear your opinion.
PS. I'd like to hear Jeff's opinion, especially because of his experience with UC's on Stackoverflow
I'm using mvc components, which replaced ascx user controls in preview 4.
Example:
http://blog.wekeroad.com/blog/asp-net-mvc-preview-4-componentcontroller-is-now-renderaction/
So, you call components action from View, which then choose View to render. You can pass data in this call also.
it is the mvc futures project. i will probably try this
http://forums.asp.net/t/1303328.aspx. I need to render menu with categories.

Resources