404 page not found for an unpublished detail page

41 views
Skip to first unread message

Yasin

unread,
Dec 6, 2017, 3:26:36 AM12/6/17
to dotCMS User Group
Hi,

I would like to preview the content of a detail page that is unpublished (in admin mode).

Instead of showing me the page, dotCMS returns a 404 not found (because the content is unpublished).

I've asked this question in the past as well and we managed it to fix it with a workaround, similar to the example below:

#if(!$UtilMethods.isSet($URLMapContent))
  #if($UtilMethods.isSet($request.getParameter("jobId")))
    #set($jobId = $request.getParameter("jobId"))
    #set($jobQuery = "+StructureName:AquentJob +AquentJob.jobId:${jobId}")
    #set($jobList = $dotcontent.pull($jobQuery, 1, "modDate desc"))
    #if($jobList.size() > 0)
      #set($job = $jobList.get(0))
      #set($URLMapContent  = $job)
    #end
  #end
#end

Unfortunately, the solution above isn't working anymore as of dotCMS 4.

When requesting a detail page whose content is unpublished it executes a query with criteria live:true deleted: false (see URLMapFilter class: https://github.com/dotCMS/core/blob/ed48dd41f1822682087e2c82e40b03ca3f6d7fae/dotCMS/src/main/java/com/dotmarketing/cms/urlmap/filters/URLMapFilter.java#L170)

But since the content is unpublished the live:true criteria won't find this piece of content. It also checks if the parameter 'previewPage' is set, if so it uses the criteria working: true instead of live:true. See: https://github.com/dotCMS/core/blob/ed48dd41f1822682087e2c82e40b03ca3f6d7fae/dotCMS/src/main/java/com/dotmarketing/cms/urlmap/filters/URLMapFilter.java#L168

This is exactly what I need, but when I pass this parameter in the URL it doesn't get recognized and still live:true is used.

What am I supposed to do to get a preview of an unpublished content?

Thnx

My old thread

http://forumarchive.dotcms.com/404-page-not-found-for-an-unpublished-detail-page-td5732682.html

Chris Falzone

unread,
Dec 6, 2017, 9:51:43 AM12/6/17
to dot...@googlegroups.com
You can preview in preview mode in the editor.  it changes the +live:true to +working:true. 

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/72997804-14b3-47e2-870b-966d7b2a674d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Message has been deleted

Yasin

unread,
Dec 6, 2017, 11:38:09 AM12/6/17
to dotCMS User Group
Just tested this on the demo site and it doesn't work (tried it in edit, preview and live mode)



Op woensdag 6 december 2017 15:51:43 UTC+1 schreef Chris Falzone:

Yasin

unread,
Dec 13, 2017, 8:41:15 AM12/13/17
to dotCMS User Group
Anyone?

Op woensdag 6 december 2017 17:38:09 UTC+1 schreef Yasin:

John Michael Thomas

unread,
Dec 13, 2017, 10:11:54 AM12/13/17
to dotCMS User Group
I don't quite understand what you're trying to do.

If you view a page in the Preview mode in the page editor, it will show you what it's going to look like if you publish it (before it's published).  I just double-checked this on demo, and it's working fine for me - when I saved changes to a piece of content on the page in draft form, or added a new content item to a container on the page, the Preview mode showed both of those changes while the Live mode did not.

So can you be more specific about what you're doing?  For example, could you post a step-by-step on how you were able to reproduce your problem on demo?


This assumes you're accessing the page without any URL parameters, but from your post it sounds like somehow you're trying to pass a URL parameter (though I'm not sure how you would do that within the page editor).
Message has been deleted
Message has been deleted
Message has been deleted

Yasin

unread,
Dec 14, 2017, 8:34:42 AM12/14/17
to dotCMS User Group
Make sure to execute the steps below fast, otherwise the demo site will automatically reset and re-publish the content (step 4)

1. Login to demo.dotcms.com
2. Go to Content -> Search
3. Select content type "News" from the dropdownlist
4. Select all items and unpublish those
5. Go to Site -> Browser
6. Open index in news-events/news/
7. Click on one of the news items in the listing (these are unpublished in step 4)
8. You will be redirected to a 404 error page instead of the DETAIL PAGE (the page where you normally see the values/fields of the content), because the news content is unpublished

I expect a redirect to the DETAIL PAGE so I can view my news content in unpublished state before actually publishing it.

Op woensdag 13 december 2017 16:11:54 UTC+1 schreef John Michael Thomas:

John Michael Thomas

unread,
Dec 15, 2017, 1:39:04 PM12/15/17
to dotCMS User Group
Ah I understand now.

So the issue is not that you can't preview a page that's unpublished, but that you can't preview a URL mapped content item which is unpublished.

Each news article on the demo site is a content item of the "News" content type, which is displayed in the detail page when you access the URL map pattern for that content item (none of the news articles has it's own page).  However the way URL maps work, if a content item is not published, attempting to access the URL map pattern for that content item will return a 404 rather than show you the detail page.  That's just how URL mapping works (I could go into the details of why, but bottom line is that the detail page is still published even when the news item isn't, so page preview applies to the detail page but not the individual content item).

So unfortunately you can't preview a URL mapped content item which is unpublished, at least not directly.  Although there are a couple ways you might be able to do this, I hesitate to suggest them unless you're pretty experienced with Velocity, since they would both require some significant coding and testing.

The closest you can come to previewing an unpublished content item is just to view a published one and see how the content from the unpublished item will be formatted when it's displayed.  Once you've verified that the formatting on the detail page is correct, you just have to make sure that the values in the fields of each unpublished content item are correct, and expect the detail page to format it correctly once it's published.

Final note: If you're using the Push Publishing feature, you can also fully preview URL mapped content items by just publishing them on the authoring server and viewing them on the front-end of the authoring server before pushing the content item to the production server.  But this obviously doesn't help if you have a single server setup.


On Wednesday, December 6, 2017 at 12:26:36 AM UTC-8, Yasin wrote:
Reply all
Reply to author
Forward
0 new messages