How can I have different templates for newly created content? I am using Drupal 7 and I need to show a different content for a custom entity depending on if the recently created content is being shown after submitting the form or if I visit the URL afterwards.

Is there a way to have different templates or is there a variable to check that tells you if it's newly created content?

I need this because I'm going to let the user share the page on social networks from that page, and I need to show a different content when people visit it afterwards.
Here's one way to solve this. In a nutshell:


Create a custom view for your entity using Display Suite or Entity View Modes.  Display Suite is preferred, as it allows you to also create custom fields and custom layouts for your entity display. This is the custom view your authors will see when they submit the entity create form.
Alter the entity creation form and add a new submit handler (be sure not to delete the default submit handler, as that will take care of creating and saving the entity before your custom handler is called).
In the new submit handler, create a form_state['redirect'] to a custom menu item
Create a custom menu item (with hook_menu) that will load your entity and pass it to a page callback
The page callback will build and return the entity custom view you defined in step 1. 


Here's the code for all this (except step 1). PLEASE NOTE: since I don't know what custom entity you are using, this example uses Basic page node (content) type. You will need to adapt to your custom entity. All this code goes in a custom module called my_custom_view.module. 

Also note: the custom view I created in Display Suite is called custom (see node_view() in the page callback).

&lt;?php

function my_custom_view_form_page_node_form_alter(&amp;$form, $form_state, $form_id) {
  $form['actions']['submit']['#submit'][] = 'my_custom_view_form_submit';
}

function my_custom_view_form_submit($form, &amp;$form_state) {
  $form_state['redirect'] = 'custom-node-view/'.$form_state['nid'];
}

function my_custom_view_menu() {
  $item = array();
  $item['custom-node-view/%node'] = array(
    'page callback' =&gt; 'my_custom_view_page',
    'page arguments' =&gt; array(1),
    'access arguments' =&gt; array('access content'),
  );
  return $item;
}

function my_custom_view_page($node) {
  return node_view($node, 'custom');
}