Automatically Migrate OrchardCMS BodyPart to LayoutPart - orchardcms

tl;dr
Within OrchardCMS, is there any way to automatically migrate the contents of a BodyPart into a LayoutPart? And if so, how?
Detail
I am upgrading an old Orchard instance (v1.8.x) that used the old BodyPart. The goal is to update OrchardCMS to the current release, and with it, migrate to the new Layout system added in v1.9. Enabling the Layout module will add the LayoutPart to content items such as Page, but the two parts both exist on the Content Definition, and moving content from the BodyPart to the LayoutPart seems to be a manual process. Is there any way to automatically migrate content from the BodyPart to the LayoutPart, perhaps even if it was nested within a single Grid->Row->Column(12)->HTML block? And if so, how?

I think you should be able to do this with a little bit of playing around and a little bit of find & replace in your code editor. I would take an empty new site and export two pages, one with content in the BodyPart and one with content in the LayoutPart they way you want it to look. You should be able to see how they are different, I haven't looked at how they export recently, but I think the body part html is contained in a pretty simple xml tag while the layout part includes some code to designate all the elements, with the html contained inside.
Next step is to export all the content from your site (using import/export) and use a good text editor to convert all the body parts into layout parts using find & Replace.
Finally, import the edited file back into the site.
I haven't tried any of this so obviously have a database backup handy and test this out in a dev environment first. Also, I'm guessing that if you follow the directions above you will end up with duplicate content in the body and layout, so you probably want to make sure your import has an empty body tag for each page.

Related

Kentico 10 - Web Part content change via database

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.

Drupal how to add a search filter to admin content page

I've never used Drupal before (development or managing content). I was asked to extend the admin content page to have a filter and simply don't know enough to get moving quickly.
Can anyone tell me if adding a search by text filter in the admin content area requires code or is there a CMS feature like adding a node for this task.
If code is required, is there something like a hook for this area? Not sure where to start. I will be investigating on my own but pointers to get me oriented to Drupal would help.
By default Drupal provides search mechanism ready to use. But there are also additional module which can improve search experience. You don't need any coding to use that search. You already have search form block ready to use.
Go to Structure -> Blocks and find block called "Search form". Now all you have to do is to put that block in some region and it will appear on front-end. Of course if it's not already styled by your theme it may be needed to put some extra CSS to make it look nice. There are also some template files which you can override and put some your HTML if you need.
There's also template file for search results page (which of course will work out of box also).
You may also need to create new block region if you want to place your form at some specific place, not covered by any existing region defined by your theme (easy thing to do!).
See https://drupal.stackexchange.com/q/30633/101329, the "Admin Views" module lets you configure the search form as you like.

Orchard Module Override a Field Driver

Hello fellow Orcharders!
I'm not sure if what I want to do is possible, but I want to override the Driver for a single Field in the Module I'm writing.
The Field I want more control over is the Content Picker field. Basically I want the Content Picker to load the shapes for their respective content items. I've looked at Sipke's Content Picker Widget for an example on how to load shapes, however I'm unsure of the best/recommended approach to implement something similar in my module.
I have the Content Picker Field attached to my Content Part, and the default Content Picker comma list of Content Item titles appears as expected. I have tried to define an Alternate in Placement.info, but I can't load the Content Item shapes from within the Alternate view.
Presumably, as per Sipke's example, these shapes need to be built in the Driver and passed along. If this is correct thing to do, how could I do this in the most Orchard-y way with minimal "hacks". Looking into the debugger, I could "hack" my way to the Field I need in my part's Driver; but the module I'm building will be reused in the future by people unfamiliar with it, and if they start adding/deleting Fields from the Content Part, I'd like everything to behave accordingly!
Of course, if I must take the "hacky" option, I'm willing to do so, but only after I've exhausted all other options. This is my first module, and I've learnt an incredible amount along the way, and I'm really trying to learn the "right" way to build an Orchard Module as best I can.
Thanks in advance!

How to integrate a "shortcode" feature in Sharepoint wikis

I would like to "customize" my sharepoint wiki by doing something very simple.
I would like to be able to run a regex on wiki pages looking for [math] and [\math] tags, then take the expression written in the middle (assume this value is stored in a variable x) and replace the whole block by
"<img src='http://latex.codecogs.com/gif.latex?" + x +"'/>"
So for example, the shortcode [math]a^2+b^2=c^2[\math] should end up being displayed as an image as follows (thanks to this online tool):
I have never developed anything in sharepoint, and I've been using it for a week.
Can anybody tell me how I should proceed to add such a feature (if it's possible)?
You can use existing solution like ShortPoint.
Sure - this is simmply done via two methods - 1) You could modify the page directly using SharePoint designer - fly in the code where you want it, 2) The better way - add your code to text file, upload the text file to a document library then use the Content Editor web part, drop it on the page, point it (through the properties) to the text file.
Note: The Content Editor part will allow you to modify the background HTML/Script, however, it has a nasty habit of overriding your code and I've had it actually duplicate itself (adding repeat scripts). Using the Text file eliminiates that issue.
If i understand you correctly, I don't think that the content editor web part is the solution you are looking for. I believe you are wanting to implement a shortcodes solution such as that found in WordPress, correct? In that case, the issue becomes a bit more complex. To really get any kind of custom code that would execute at the necessary stages, you would need a custom solution either implementing additional functionality in the existing rich text editor, or roll your own custom rich text editor.
At that point, you would have complete control over how the content is parsed and interpreted, so you could have both server-side and client side processing. You could make use of templating engines like mustache or handlebars.
To do this, you would need to write your own Custom field type, inherit from SPFieldMultiLineText, override the property FieldRenderingControl, and return your custom control. That way you have the option of implementing it in several different places (custom pege fields in a page layout, custom webparts, custom lists, etc.) and you still get the benefits you want from the out-of-the-box control.

Dividing long content to subpages

I need to divide long content to sub-pages.
Rule for dividing: Heading1 (H1)
Cms-system: MODX Evolution
As far as i know, there is nothing in modx to use for this kind of problem.
I probably got to do this manually anyway, but i still would like to know if there is a way to do this in MODX Evo / Revo.
Edit:
I need to do this in MODX; sub-pages got to be actual subpages, and original page becomes to container.
Navigation will be done with wayfinder.
Edit2:
All done.. manually. Question still open, though.
This is not possible out of the box and I don't know of any extra that archieves what you want. You would have to write a plugin that acts everytime you save a resource and split up the content, create/delete sibling resources as needed etc. Sounds like a lot of work for what you want to archieve to me.
I suppose you have a look at the MIGX extra. It provides you with a TV with the possibility to store an indefinite amount of distinct TV content sets. Have a look at the documentation and Mark Hamstra's tutorial (with screenshots) to see how it is done. You should define one MIGX entry to consist of a text field for the <h1> and a rich text field for the content of the "subpage".
Afterwards, you can use form customization to hide the original content field and display your MIGX Tv instead.
I think, this is a much easier way to archieve, what you want, and can't think of any way, where you would benefit from actual subpages.
Edit: Sorry, I just recognized that you were asking about Evolution, not Revolution. My solution would work in Revo, but I don't think there's something like MIGX for Evo. Sorry, my mistake.
not 'out of the box' you will have to run your content through a snippet to parse it into separate divs or something that you can run some javascript on to possibly 'tab' the content.
If you need to show the 'subpages' in your navigation, you will probably have to use the gatResources extra to parse your content ~ which will be very expensive on resource usage.
You can (depending on how you're using the tree) just create actual sub resources under the parent resource, using Ditto or Wayfinder to build navigation for it.
If you can't use the tree like that (though from your description I think you can), you could also set up a number of template variables ("content1", "content2", "content3" etc) and show that with a simple snippet or so.

Resources