I have a project I have attached Piranha CMS too. That bit worked fine.... However the pages I have already created and the template are not displaying in the CMS edit.
Steps I have done.
imported Piranha from guget.
Altered webconfig to passive.
removed piranha connection section.
changed connection to forms.
Alter connection string to match sql-server DB.
altered the global.config
built DB in sql server
Built project setup admin and the DB structure built followed.
Like I said it has built ok... But only the standard template. I'm guessing I've ether missed a step or there are steps to go. Can you advise me were to go next?
The webpage site currently just a home page.. The remaining pages are not completed. But if I don't crack this point there is little point continuing.
I think you have to add the pages into Piranha through the manager interface, then use the Permalink as the argument to fetch the Piranha managed content from Piranha. I don't think Piranha will parse your view/controller/routes and automatically import them into the site definition.
I use Piranha in my views like this;
#Html.ActionLink((string)Model.CMSData.Properties.WebSiteTitle, "Index", "Home", new { area = "" }, new { #class = "navbar-brand" })
I embed the CMS data into my model based on the examples in the Getting Started section;
public object CMSData = Piranha.Models.PageModel.GetByPermalink("my-permalink") ;
This enables me to weave in CMS content to my Model and then use it inside my View.
Related
I have just started using Piranha CMS with my existing MVC4 website. I have a database hosted in Azure and ideally I want Piranha to control just this i.e I don't want it to alter the pages etc.
Is this possible? I have set my databases connection string in the web.config on the Piranha key and have set passiveMode to true
So the reiterate I want Piranha to just update the data in the database, if this is possible how do I go about doing it?
Yes!
If you set passivemode to true the entire routing for pages & posts will be disabled. The basic functionality for getting uploaded media files from the CMS will still be active.
You will then have to manually get the CMS data from you controllers in you actions, for example:
public class HomeController : Controller
{
public ActionResult Index() {
//
// Let's say you have a page with the permalink 'start'
//
var cmsData = Piranha.PageModel.GetByPermalink("start");
return View(cmsData);
}
}
Regards
I have created a visual web part that has one entry form, it contains 10 textboxes and a submit button to insert the data.
Now on click of submit button it redirects to another page(page is application page deployed under layout folder of same site. this page is added in same web part solution by adding new item).
I'm able to redirect to application page using SPUtility.Redirect(). but not sure about best approach to pass the data from web part page to application.
I think that query string is not a good solution. Also enabling session is manual work on each environment(as i experienced that in one server when i created session variable i got an error to enable it, but in other dev server i was able to do that).
I have done this using a public class in user control .cs page and defined all fields as static variables in side the class. now I'm able to access them in application page added inside layout folder of same project solution. Not sure if it is right approach , but it works
I have added a global site region to my site and filled it with some content. How can I read this content from page view and/or layout?
This feature differs a bit between WebPages & MVC, the reason for this being that in WebPages (like WebForms) a Layout-page have a different model than the actual page being executed. If you use WebPages you simply add the following line first in the Layout page:
#inherits Piranha.WebPages.LayoutPage
This will automatically load the layout page model and all the global regions.
If you're using MVC this can't be done automatically as the Layout doesn't have a model. You can simply add the following in your Layout-page:
#{
Piranha.Models.PageModel global;
if (HttpContext.Current.Items["Piranha_CurrentPage"] != null) {
var current =
(Piranha.Models.Page)HttpContext.Current.Items["Piranha_CurrentPage"];
global = Piranha.Models.PageModel.GetBySite(current.SiteTreeId);
} else {
global = Piranha.Models.PageModel.GetBySite(Piranha.Config.SiteTreeId);
}
}
This snippet loads the layout page from:
If it's a page is displayed it loads the site tree the page is contained in
If it's a post it loads the site tree from the current site.
Hope this helps you!
Regards
/HÃ¥kan
I have a custom list definition in production environment with list instances created with the following definition:
<View BaseViewID="0" Type="HTML" WebPartZoneID="Main" DisplayName="All Items" DefaultView="TRUE" MobileView="True" MobileDefaultView="False" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/issues.png" Url="Forms/AllItems.aspx">
I need to changing the setup path in some way so the AllItems.aspx view of the document library displays documents from it's parent site document library by e.g. CQWP. I've attempted this by using SPView.SetViewXml() but this has no affect.
I have attempted to follow Stefan Stanev's SharePoint blog
I've successfully changed the setup path in development with Unghost a custom SPView but I really do not want to go down this path.
I have customized the viewpage.aspx by mapping to templates\pages and editting / adding the required web part and adding feature upgrading to create a new view set it as default, change the ViewXml by calling SPView.SetViewXml but this does not work.
Is there a way of updating the content database post production to change and customise AllItems.aspx of a custom document library without directly querying content database?
I'm upgrading from .NET 2.0 to MVC 4. Back in .NET 2.0 webform, we had to inject license information on the fly to the footer of the software by override the "Render" function in .aspx.cs page (using HtmlTextWriter), find a particular spot of the footer and then insert the license text info there.
The reason I don't want to directly put that in the viewstart page or any razor page themselves using HTMLhelper is because I don't want my customers to mess with it. So hard code is not an option.
I use Glimpse and I see Glimpse is enabled by adding a HTTPModule,etc in web.config and magically, an icon appears on my app. Something similar ?
Bottom line is, I need to hijack the finished HTML output, modify it and return the final result to client.
How do you do this in MVC? HttpModule?
Thanks!
Glimpse uses a feature of ASP.NET called a ResponseFilter to change the output HTML on the fly.
The ResponseFilter, in the case of Glimpse, is set inside the HttpModule - but it could be set anywhere.
Four Guys From Rolla has an old but still relevant article on how to create ResonseFilters.