I want to manipulate data directly into database.
But the changes not reflected in Orchard Website.
How can tell to Orchard clear all database cache after making some data changes in database?
I assume you are adding records to the table LayerPartRecord? This won't work because layers are content items in Orchard, they are built from more tables than just the layerpartrecord table. You will have to add records to several other tables. It begs the question, why are you trying to do this? Orchard does not lend itself to direct database modification. Sebastien Ros talks a little about Orchards database structure here, if you really have your heart set on modifying the database: http://sebastienros.com/understanding-orchard-s-database, but I'd definitely say it is more trouble than it is worth.
Instead you can create layers using the Orchard command line:
layer create Authenticated /LayerRule:"authenticated" /Description:"The widgets in this layer are displayed when the user is authenticated"
Or use the Import/Export module, so your import code will look something like this:
<Layer Id="/Layer.LayerName=Authenticated" Status="Published">
<CommonPart Owner="/User.UserName=admin" CreatedUtc="2014-07-01T12:22:26Z" PublishedUtc="2014-07-01T12:22:26Z" ModifiedUtc="2014-07-01T12:22:26Z"/>
<LayerPart Name="Authenticated" Description="The widgets in this layer are displayed when the user is authenticated" LayerRule="authenticated"/>
</Layer>
You can disable SysCache module, then Orchard won't cache database output. Otherwise you can just restart your website, that will also clear database cache.
Also make sure changes you make to the database are saved there. For example WebMatrix won't save row until you fully deselect it.
Related
i was trying to understand in the Kentico's database model how can i change the web parts content using a database script.
So, basically i have a website based on Kentico with several articles, and internal hyperlinks in its content. But the problem is that the format of those hyperlinks are actually invalid. And i was looking for a way to build a script and do a bulk-update in order to replace some characters and update those hyperlinks to the valid format.
Any idea how can i build the query to get the content of all web parts used in all published pages.
Thank you
It depends on your web parts and how the content is rendered. There are different ways that web parts render their content:
The web part layout is used for markup
The ASCX file for the web part is used for markup
The web part makes use of a repeater that uses a Transformation to render the markup- The markup is generated in code behind
The last one can be tricky to change depending on the web part and whether you have access to all the code behind, but the others you can change either in code in your solution or within the Administration area itself.
Doing this in SQL would probably require a combination of T-SQL XML support and regular expressions to find what you're looking for. you effectively need to look in the CMS_WebPart and CMS_WebPartLayout tables to find what you're looking for.
However, reading your query, I'm not 100% sure you're talking about web parts, (my apologies if you are) as you talk about links in the article content itself. If these are set using the Editable text web part, then you need to look in the CMS_Document table at the DocumentContent field to find the links to replace. But you then need to look at how to correctly format those links going forward so that you do not need to repeat this process later.
Note:
You need to be really careful when doing this in SQL to make sure that you don't create invalid XML. Things go bad when you do that.
This won't flush your cache, so you'll need to clear your cache manually afterwards.
If you're using out-of-the-box web parts, you should really make a copy of them and use the copy if you're going to modify, this way, you're less likely to have pain in future upgrades.
Typically "content" is not set in a webpart. Webparts are configured to retrieve content from page types. There is an exception to this with specific webparts like Editable Text, Static Text, Static HTML, etc.
The configuration of a webpart is stored at the template level in the cms_pagetemplate table. The configuration for ALL webparts on that page template are stored in the PageTemplateWebParts field. So you'd have to parse through the XML and get the proper webpart and then perform an update on that field. You maybe able to do a regex to find that content and replace it as well.
Not ideal to do this via SQL simply because of version history and it can cause a lot of problems later on. I'd suggest finding out which API calls you can make to perform these updates and write a small program for it.
I created a custom Type that has a UserPart attached to it.
According to this issue on GitHub you can't add a CommonPart to content that also has a UserPart because it causes a StackOverflowException but I would still like items of my custom Type to show up in the content list. I already store CreatedUtc and PublishedUtc in the custom PartRecord, can I manually plug these in somewhere?
EDIT: For clarification, my specific scenario is that I am building a public facing Orchard website based on existing data that was used in a private application up to this point. I have a legacy table with user accounts that need to be mapped to Orchard Users but they also represent travel agencies that visitors should be able to browse and that Orchard admins should easily be able to edit and create through the Dashboard. I got the idea to create a TravelAgency type with a UserPart from Sipke's webshop tutorial
Content Types do not require to have a CommonPart to show in the Content List. If i remember properly its done by triggering the Creatable() in your migrations.
Also if you have a UserPart, you could Lazy loaded or just reference it via Foreign Key.
Why would you like something like that to be part of the Content List? I usually keep my business-specific Content Types tucked away in a nice section, so there are easier to visualise and use for users.
There is definitely a bug but as they comment you could extend taxonomies to accomplish your task and keep in mind sometimes changing the Orchard Codebase might fit your purposes, you only have to keep track of your changes when you upgrade next time. I have done it a couple of occasions to fit my projects.
If i remember properly, its been a while.. If you look in the core code where the Content List is created it looks for Creatable() Types. digging even more inside the code, chances are the Query in charge will join the CommonPart, hence your problem. You could easily add another query in the controller and add whatever you are after. The problem though, will be refactoring the rest of actions to accommodate your your type too. Way easier isolating your new Type. had to look at it for you, check this baby: Orchard.Core.Contents.Controllers.AdminController
Looking through orchard examples and I was wondering when is the correct time to use (for exmaple im using customer so...)
CustomerPart or CustomerPartRecord. when referring to them in Orchard projects?
Most of the time you want to use the part. The record is used for storing the data in the part to the database. View templates and Drivers will refer to the part and the handler will say how the record is persisted.
If you follow the example through for Creating a Simple Orchard Module and do as they do, it should become clearer. In particular check the 'Creating the Model for the Part' section.
I need to make a table with an editable column. Each row is a separate record. I want to be able to display hundreds of records, perform edits to them and then submit them back to the server for updating. I am not sure this is really supported by the forms infrastructure.
Is there a way to make a repeatable form such that I would get a list of results back? This seems to be the closest solution I can envision without writing my own in javascript. Any ideas on this would be welcome.
Don't reinvent the wheel. Just use one of the full featured js grids like jqgrid or extjs if you want the full pack of UI components.
I use jqgrid with yesod, edit rows both in grid and in outside panel and submit the changes back.
I think the problem with your approach is that you found your hammer (yesod forms library) and now looking for a nail.
You don't have to use every bit of yesod just because its there.
I've made a mess of MOSS (well not really, just that I've created some site columns that are now impossible to delete).
Is there any way I can revert to a default installation without reinstalling everything?
Failing that is there a way to force delete site columns?
Update
Basically another "typical day developing around Sharepoint..." moto, with Sharepoint it is 100% probable something will go wrong.
I have Site Columns that can't be deleted, because they're "bound to a content type, that I've already deleted"
If you are created custom columns on Document Library level you just need to delete Document Library
In case you created custom columns at site collection level you should delete your site collection and create a new one. New site collection will not be affected unless you made some non-supported customizations to "12 hive".
In both cases you can solve the problem without reinstallation.
Hope it helps,