tomusborne / generateblocks

GenerateBlocks is a small collection of lightweight WordPress blocks that can accomplish nearly anything.
https://generateblocks.com
198 stars 23 forks source link

GB 2.0 Dynamic Tag Modified date - Required to render does not work #1505

Closed diggeddy closed 19 hours ago

diggeddy commented 3 days ago

Description

GB 1.0 Dynamic data has option to display Modified Date or fallback to the Published Date so only the latest date can be displayed.

tomusborne commented 3 days ago

The Modified Date should fallback to the published date if it hasn't been modified. So if someone wants to output the modified date ever, they should go with that tag. Otherwise, the published date will only ever show the date it was published.

Is that not what's happening on your end?

diggeddy commented 1 day ago

It is working as you describe. Bit of a misunderstanding on my part. I expected there to be an option to fallback as per 1.0. However, the Required to render should provide the option when a user want to remove the date. But this option doesn't work for this tag. This looks like a bug and updated issue to reflect that.

tomusborne commented 1 day ago

I think to do that we would need to short-circuit the function if the modified date equals the published date and not return anything.

rsm0128 commented 22 hours ago

@tomusborne I don't believe this is a bug. The modified_date refers to the post's modified date, and it retrieves data from the post_modified column in the database. The post_modified value always exists for a post because it is set when the post is created. Therefore, there is no scenario where a post has a null post_modified value. In the database, the column type is DATETIME and is defined as NOT NULL, which means it cannot be an empty string either.

tomusborne commented 22 hours ago

@rsm0128 Yea, although I think it should be possible for the user to output only the modified date (and not the published date) if it exists. For example:

Date published: xx / Date modified: xx

Working on a potential solution for this right now.

rsm0128 commented 22 hours ago

I think {{modified_date}} should be replaced with {{published_date}} in /src/blocks/query/templates.js file. https://github.com/tomusborne/generateblocks/blob/release/2.0.0/src/blocks/query/templates.js#L124 https://github.com/tomusborne/generateblocks/blob/release/2.0.0/src/blocks/query/templates.js#L172 https://github.com/tomusborne/generateblocks/blob/release/2.0.0/src/blocks/query/templates.js#L222 https://github.com/tomusborne/generateblocks/blob/release/2.0.0/src/blocks/query/templates.js#L286