Kamran
Kamran

Reputation: 4100

sitecore publish item from web to master

I am working with Sitecore Intranet Portal. I am using web database for CD.

If a user change his email Id. How would I publish this to master database.

I am using this code to publish item from web to master db.

// The publishOptions determine the source and target database,
// the publish mode and language, and the publish date
            var publishOptions =
              new PublishOptions(Database.GetDatabase("web"), Database.GetDatabase("master"),
                                                     PublishMode.SingleItem,
                                                     item.Language,
                                                     DateTime.Now);
            var publisher = new Publisher(publishOptions);

            // Choose where to publish from
            publisher.Options.RootItem = item;

            // Publish children as well?
            publisher.Options.Deep = true;

            // Do the publish!
            publisher.Publish();

It would be nice to know the correct procedure.

Upvotes: 0

Views: 1718

Answers (4)

Srinivas Ramakrishna
Srinivas Ramakrishna

Reputation: 1335

The best practice to store the user information in the Core database. Sitecore is using ASP.NET membership to manage the user accounts. I recommend you to store all the user info in the core DB.

Sitecore doesn't provide any option to publish data from web to master, however, it has provides you an option to transfer data from web DB to master DB.

Check out my blog Transfer Items from Web to Master Database for complete details on transferring the data from one DB to another DB

Step 1: Login to Sitecore desktop mode.

Step 2: Select the source database from where you need to transfer the items. If you want to transfer from Web to Master then select Web Database in the right-hand bottom corner.

Step 3: Open the content editor and select the item which you would like to transfer.

Step 4: Right click on the Item and select Copying>>Transfer and click on the transfer button

Step 5: In the Transfer window verify if the source item is selected properly or not.

Step 6: Click on Next to continue. In this window first thing is to select the destination database to which you need to transfer. The second thing is to select the parent item or the destination folder where you need to place this item. In my case, I need to select Layout because sublayouts are present in the layouts item.

Step 7: Click on next, here you will get an option which says include subitems. Select the checkbox if you need to restore the subitems also else uncheck the box to transfer only the selected item.

Step 8: Click on transfer button and it will start the transfer process. Close the dialog box once the transfer is completed.

Upvotes: 0

Hishaam Namooya
Hishaam Namooya

Reputation: 1081

You can make use of package to transfer your item from web to master. You can follow the following steps:

  1. Create your item package from web.

  2. Use the tool that i have developed to convert the destination of the items. That is, change from web to master. The tool is found on marketplace at Sitecore package modifier.

  3. Install the modified package on the master database.

Another solution is to have a schedule job that create the package from web, modified it and install it on the master database. This hence require no manual intervention.

I prefer to use this method than the sitecore transfer method because the transfer method tends to timeout or cause an error if there are lots of items to transfer.

Upvotes: 0

Dražen Janjiček
Dražen Janjiček

Reputation: 409

Either use an external database or use Sitecore users for a certain domain and store everything in the core database. The core database is commonly shared between all environments

Upvotes: 0

Vlad Iobagiu
Vlad Iobagiu

Reputation: 4118

To publish from web to master is a bad practice.

This kind of content is named User Generated Content. I suggested to use this approach :

https://sitecore.unic.com/2015/07/16/user-generated-content-in-a-security-hardened-environment

Or you can use webservices. This allows all content (even user-generated) to be authored in your CM instance. This allows you to leverage the capabilities of the platform for workflow, publishing, etc.

Upvotes: 2

Related Questions