Working with pages programmatically
Hi all,
I want to work with pages programmatically, if i want to add this code for example, where shoud i insert it?:
Please i am new with Sitefinity, i need to know, if i am editiing my sitefinity project in Visual Studio, which files should i edit or create to execute the previous code.. Thanks in advance.
Hi, I think we spoke via email but I'll post our discussion here too in case anyone else has the same question.
The code you’ve posted below is for Sitefinity 3.7, and is not compatible with the latest release. If you're using SF 4 or higher, you’ll want to use the new API.
Sample code for creating and saving pages using code is available in the documentation: http://www.sitefinity.com/documentation/documentationarticles/developers-guide/sitefinity-essentials/pages/creating-pages
You can either use the standard PageManager API or the FluentAPI, both methods are explained and have sample code in the page linked above.
You could put execute this on a blank webforms page (create a test.aspx page and put it in the code behind) and run that page to execute it. You can also place it in a user control (ascx file) as a widget and drop it on a page to run it.
Alternatively you could wrap it in a module, but this is more advanced and probably only necessary if you need something reusable. For more on module creation take a look at the testimonials intra site module example: http://www.sitefinity.com/documentation/documentationarticles/developers-guide/how-to/how-to-create-a-testimonials-intra-site-module
Hope this is helpful!
Hello,
If Mr. Morales is still around Sitefinity, how would you go about using this, or similar, code in order to upgrade your Custom 404 pages for Sitefinity 3.7 to the latest version of Sitefinity?
Ideally, we'd like to search a certain search index for pages that may interest the visitor.
Thanks.
Hello,
If you have created these pages inside Sitefinity 3.7 they will be migrated during the migration process. If the pages are created by code you need to recreate them using our Sitefinity documentation for pages.
Regards,
Stefani Tacheva
Telerik