Sitecore: Create component and insert into placeholder on page creation - sitecore

We have developed a Sitecore site for a client who will primarily be using Page Editor. We've built page type layouts and then componentized everything else, including sub-layouts of content. This allows them the most flexibility when building pages.
So, an author goes to a page selects the main content area (Placeholder) of the page and inserts basic building block components that we've created. These include Rich Text box, page promos, etc. they can use these to build pretty rich pages with lengthy content.
All page components have the same Datasource Location, which is a "Page Components" folder that's setup as an item bucket.
This is all working well so far.
Now, I'm trying to make it so when a page is created a specific component is created, inserted into to our "Page Components" bucket and placed in a specific placeholder on the page.
I've been trying to build a Branch Template to accomplish this, but I don't see how to specify that the new component should be stored in our bucket location, instead of directly underneath the Page item. Also, how to make the component show up in the placeholder that I want on the page.
Is this possible? Thanks in advance for you help!

You will want to use a command template for this, since you are desiring to programmatically bypass Sitecore's standard layout configurations and branch template creation.
On your page template standard values, you will want to add the sublayout to the presentation details so you can hook the datasource in programmatically after creation.
The fundamental flow in the command will be as follows:
Create the desired page item
Create the desired component datasource in the bucket location
Search the layout definition of the created page item to find the appropriate sublayout to bind to.
Alter the datasource on the sublayout to bind to the datasource you created.
As #jammykam mentioned, there is a recent blog post now available.

Related

Custom Sitecore Microsite Resolver

We recently worked with a client to create a series of smaller sites that were composed of the same templates and components being developed for their main flagship site. These microsites needed to conform to a common layout but required the ability to have unique branding in the header as well as unique hostnames or domain names. Setting up a new site in Sitecore is a fairly straightforward process, typically – you create the new home node in the content tree then add a declaration to the web.config. In this particular scenario however, the client did not want to have to make a configuration update to deploy each new microsite – they simply wanted to create the content for it, publish it, and have it available to their audiences immediately.
I have gone through a link (https://www.sitecore.net/learn/blogs/technical-blogs/chris-sulham/posts/2015/01/quick-guide.aspx) but found incomplete information.
The general approach to solve this requirement is to store the site definition data in the Sitecore database as a 'site definition' of some kind. You will then need a processor that will initialize the sites list after the file configs have been read and update site definitions or add to the list.
#jammykam pointed to the Dynamic Sites Manager as an example of this, so you may want to start there.
Since authors typically define these new sites after Sitecore start-up, you also will need some functionality (usually a ribbon button or publishing event handler) that will let you trigger an update of the current site list in application memory with the latest data.

URLs of pages on which item appears in Sitecore

In Sitecore, how can I get a list of all pages on which an item appears? Thanks
Internally Sitecore maintains a database of references between Items called the Link Database. You can query this by using the "Links" dropdown on the "Navigate" tab on the Content Editor ribbon. That may give you the information you need.
(You can also query the Links Database via code - See example code on http://laubplusco.net/sitecore-item-extensions-get-referrers-as-items/ for one example of doing this - or the docs in SDN)
If the relations to your target Item are via selection field types (multilist, treeview etc) or via the DataSource property of Renderings/Sublayouts/etc then you should be able to select the item you're interested in and click the "Links" dropdown to see a list of the relationships Sitecore has recorded. This will list system relationships (which template does this item use) as well as the sort of relationships you're interested in where one item points at another item.
Note that this approach cannot tell you about some types of relationship: the most common sort being ones which are calculated at runtime. (EG API queries, or searches) because those relationships don't exist in the Links Database.
-- edited to add --
You ask about getting the URLs for these Items. In code you can get the URL for an item by calling LinkManager.GetItemUrl() and passing in the item you're interested in. That gives you the public website URL, rather than the Sitecore Item Path that you'd get directly from the Link Database.

adding custom page's link in homepage in opencart

I am new in opencart, and I am trying to build a new eCommerce site using opencart where I need to add some custom static page ( some additional page ). So I follow the link New Page For OpenCart and opencart php custom page without using the "information" feature, and I can create a new custom page. But my problem is, how can I get this page's link on my home and others page so that people view my page.
If you are creating a new page that way, you will be to access the page (called "newpage" for example) at: /index.php?route=common/newpage or /index.php?route=common/home/newpage depending how you set it up.
The simplest way of creating a new page is to create a new information page. You can input your custom html there if needs be. The link would then look like:
/index.php?route=information/information&information_id=x where the id is the id of your new page.
To add this link into your main menu you can edit template/common/header.tpl and hardcode in the new link.
Creating your link would depend greatly on how the page has been created, and where it's located.
Urls are built based on the location ie: route of your controller.
Let's say your new page has been built in:
catalog/controller/common/mypage.php
Obviously you'll need to follow the code standards listed in the posts you referenced for created a correct class that extends the Controller, a language file, a model class (if your page needs to interact with the database) and a view file.
Once all that is correct via the previous posts you can create a link anywhere on the catalog (front) by calling the url class and passing in the required information.
You'll need to pass in a route, any arguments such as an id or customer, and whether the url should be secure.
$link = $this->url->link('common/mypage', 'mypage_id=' . $this->request->get['mypage_id'], 'SSL');
$arguments and 'SSL' being optional if they're needed.

SharePoint Word Template central repository

I have to build something like this:
All our Word templates are saved in a central SharePoint Site (Document Library). For every customer we have a dedicated sharepoint workspace. In the workspace there should be a view, webpart or something like this where the all the files from the central template library should be shown. The template files should not lay NOT in the customer workspace.
When an user clicks on a word template in this view, webpart, the document should be opened in word and when the users edits and saves the document, it should be saved in the customer workspace (without prompting for a path).
I know that Content Types would be a possiblity for this, but this is too complicated for our intention.
Is there a possiblity influence word on opening where the document should be saved? Like an Parameter in the URL?
Au contraire, document types are the only way you will be able to get out of this mess unscathed.
For each "template" you can create a "site content type".
You will be able to set the url for that content type to the "template document" in your main site.
Customer site document libraries will then be able to create a "new" document and it will default to the library where they click the data from.
See
Change a content type for a list or library

Reload googlemaps after user clicks a link in Django

I am doing a project in Django and i want to have some google maps displayed in my site. So, i installed django-easy-maps and successfully used it in a sample template. So, i am ready with my maps.
The interface i want to implement is this
http://i49.tinypic.com/sowm74.png
I want to display the maps where the Hellow World! container is and with different links on the sidebar i want to refresh the map being displayed on user click without reloading the page.
I did some researching and it seems Ajax is the solution...
Can anybody tell me how i might achieve this (with or without Ajax ) ?
Sorry for sounding like a noob but i am fairly new to this.
The basic steps are:
Create a view for the Google Maps section to the right. This view does not return a full HTML page but only the HTML for that section (which contains your Google Maps map).
When the user clicks on a link on the left, use JavaScript to perform an ajax call to request that page. In short this means: attach an event handler to the onclick event of those links and in code you can perform an ajax call .Many people use a JavaScript library for this purpose, such as jQuery (which has $.ajax()).
You can then use JavaScript to put the received HTML inside the container on the right (using $.html()).