Forum

Thread tagged as: Question, Error, Blog

Blog Post - What is public and what is not in a draft or timed publish date?

We have a timing issue that came up with a blog post. Here is what happened:

  1. Yesterday, this blog post was set to 'Published' mode and scheduled to publish on 3/7 at 12:01 am PT.

  2. At 10:30 pm last night (3/6), it was scheduled to publish was changed to 3/8 at 12:01am PT and changed the status back to 'Draft'.

  3. Since the post was never published, no alert should have gone out. But somehow Google crawled the site anyway and published an alert for the story.

By 'publishing' the post (even though the date is set to the future) does it somehow reveal the metadata to Google so it can be crawled?

Leigh C

Leigh C 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

By 'publishing' the post (even though the date is set to the future) does it somehow reveal the metadata to Google so it can be crawled?

No, it shouldn't do. The basic Blog functionality doesn't return any posts unless they hit their publish date.

Have you checked the time on your server?

Leigh C

Leigh C 0 points

Checking on the server time. But I see I also have a line in the config file (but it's hidden for now):

define('PERCH_TZ', 'America/Los_Angeles');

I think I hid it to avoid messing up anything else in the CMS. Does changing the time zone in the config.php file affect anything other controls or settings?

Drew McLellan

Drew McLellan 2638 points
Perch Support

What do you mean by hidden?

Leigh C

Leigh C 0 points

I mean I had the line of code hidden for future use because this has come up before. But I asked my client and they other publications are posting on time, so it's not a time zone issue.

He did realize though the Google Tag Manager script is on the page. Is it possible the initial publication gave the tag manager the meta data it needed to launch an alert even though the post wasn't actually publicly visible?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Do you also add that script to the post preview? Have you been using the post preview?

Leigh C

Leigh C 0 points

Yes we're using the Preview option. But how do I know if it's been added to that as well? I thought the preview was rewrite, not it's own page. Where do I look to confirm that?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Did you not build the site? I don't know how your site is put together, so I don't really have any insights on that.

Leigh C

Leigh C 0 points

Yes I built the site, but I can't remember where the Preview setting is. Is it based on a template? I don't see where I could have put it in the post.php page. Please advise.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Usually preview will use the same master page as a post.

Leigh C

Leigh C 0 points

Ok so if that's true, then how can I resolve the Google Tag Manager issue if the script exists on the same page that the preview generates? Is there a way to seperate them out so drafts and previews don't trigger the alerts (meaning, they don't make them visible to any web service, just CMS editors)?

Duncan Revell

Duncan Revell 78 points
Registered Developer

Whenever you view a preview, ?preview=all is added to the url, so wrap your Google code in an if statement that checks for that url parameter.

Leigh C

Leigh C 0 points

Ah, cool - I'll try that.

Leigh C

Leigh C 0 points

Actually can you give me an example of this IF statement. I haven't done one with a URL parameter before....

Drew McLellan

Drew McLellan 2638 points
Perch Support

if (perch_get('preview')) {
...
}
Leigh C

Leigh C 0 points

Hi all - I need some assistance here. We still have an issue with posts going to "Published" earlier than expected.

Here is what I have going -

1) post.php has this line at the top just below the runtime:

<?php perch_blog_check_preview(); ?>

2) the Post page in the CMS control panel has two paths, one for the posts themselves, and one for the previews:

community/[slug:s]

and

community/[slug:s]/[preview:preview]

Preview has been working just fine, but every once in while a post set for, say 6am pacific time, gets published hours before then. No consistency to it. I haven't added the IF statement mentioned above yet because I don't really know the how it gets worked into item 1 above. I'd appreciate some suggestions or if the paths or messing this up, suggestions on correcting those. Though I don't see how they could be the issue....

Duncan Revell

Duncan Revell 78 points
Registered Developer

Without seeing more of the page or templates, it's hard to guess exactly what is going on.

However, just guessing, your post.php must include some code that outputs the Google Tag manager script onto your page (using perch_layout possibly?). The use of perch_get('preview') is to work out when an admin is viewing the draft post and then ensure that the Google Tag manager script isn't being output.

You need to find out where the Google Tag manager script is being added to the page - then we can try and wrap that in some code that basically says "if this is a preview of the post, don't show this script".