Forum
postURL returning empty
Hi there,
In the Blog app I've created a new section which uses a custom post type 'posts/post_timeline.html' to create the relevant fields and display them. I'd like to link to individual posts from the excerpts that I'm displaying, but adding:
<a href="<perch:blog id="postURL" type="hidden" />" rel="bookmark" class="p-name">
<perch:blog id="postTitle" type="text" label="Title" required="true" size="xl autowidth" suppress="true" order="1" />
</a>
returns
<a href>
// content
</a>
in HTML.
The 'post_timeline.html' template looks like this:
<h1>
<a href="<perch:blog id="postURL" type="hidden" />" rel="bookmark" class="p-name">
<perch:blog id="postTitle" type="text" label="Title" required="true" size="xl autowidth" suppress="true" order="1" />
</a>
</h1>
<perch:blocks>
<perch:block type="bl-writing" label="Writing">
<div class="tl-entry tl-writing">
<a href="<perch:blog id="postURL" type="hidden" rel="bookmark" class="p-name"/>" >
<perch:blog id="writing" type="textarea" editor="redactor" markdown="false" html="true" size="autowidth" label="Your Content" suppress="true" order="1"/>
<perch:blog id="excerpt" type="textarea" editor="redactor" markdown="false" html="true" size="m" words="30" label="Excerpt for the Timeline (max 30 words)" order="2"/>
</a>
</div>
</perch:block>
<perch:block type="bl-social" label="Social Media">
<div class="tl-entry tl-social">
<perch:blog id="social-embed" type="text" html="true" label="Embed code for Twitter or Instagram goes here" order="1"/>
</div>
</perch:block>
<perch:block type="bl-sound" label="Sound">
<div class="tl-entry tl-sound">
<perch:blog id="sound-embed" type="text" html="true" label="Embed code for Mixcloud goes here" order="1" />
<perch:blog id="sound-descr" type="textarea" label="Description of the sound (max 30 words)" markdown="false" editor="redactor" html="true" words="30" suppress="true" order="2"/>
</div>
</perch:block>
<perch:block type="bl-video" label="Video">
<div class="tl-entry tl-video">
<perch:blog id="video" type="vimeo" label="Vimeo video URL" />
<perch:blog id="video-descr" type="textarea" label="Accompanying description" markdown="false" editor="redactor" html="true" order="2" />
</div>
</perch:block>
<perch:block type="bl-article" label="External Article">
<div class="tl-entry tl-article">
<perch:blog id="article-embed" type="text" label="URL of external article page goes here. This block is unique in that it won't appear in your blog post, but can appear on the timeline." urlify="true" order="1"/>
<perch:blog id="article-descr" type="textarea" label="Brief outline of the article (max 30 words)" markdown="false" editor="redactor" html="true" words="30" order="2" />
</div>
</perch:block>
</perch:blocks>
<p class="meta">
<perch:blog id="month-selector" type="select" label="Timeline Month" options="February|feb, March|mar, April|apr, May|may, June|jun, July|jul, August|aug, September|sep, October|oct, November|nov" allowempty="false" help="Select a month for this post to appear on the Timeline." order="3"/>
<time class="dt-published" datetime="<perch:blog id="postDateTime" type="date" label="Date" time="true" format="Y-m-d H:i:s" divider-before="Meta information" />">
<perch:blog id="postDateTime" type="date" time="true" format="%d %B %Y" />
</time>
<perch:if exists="authorGivenName">
by <span class="p-author h-card"><perch:blog id="authorGivenName" type="hidden" /> <perch:blog id="authorFamilyName" type="hidden" /></span>
</perch:if>
<perch:categories id="categories" set="blog" label="Categories" display-as="checkboxes">
<a href="archive.php?cat=<perch:category id="catSlug" type="slug" />" class="p-category">
<perch:category id="catTitle" type="text" />
</a>
</perch:categories>
</p>
No errors thrown, diagnostics report look like this:
HEALTH CHECK
Perch is up to date
PHP 5.6.6 is up to date
MySQL 5.5.43-0ubuntu0.14.04.1-log is up to date
Image processing available
SUMMARY INFORMATION
Perch: 2.8.6, PHP: 5.6.6, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $, with PDO
Server OS: Linux, fpm-fcgi
Installed apps: content (2.8.6), assets (2.8.6), categories (2.8.6), perch_blog (4.6), perch_forms (1.8.3), perch_backup (1.2), perch_twitter (3.5.1)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_twitter', 'perch_forms', 'perch_blog' );
PERCH_LOGINPATH: /perch
PERCH_PATH: /srv/users/serverpilot/apps/stagingwalesinvenice/public/perch
PERCH_CORE: /srv/users/serverpilot/apps/stagingwalesinvenice/public/perch/core
PERCH_RESFILEPATH: /srv/users/serverpilot/apps/stagingwalesinvenice/public/perch/resources
Image manipulation: GD
PHP limits: Max upload 128M, Max POST 128M, Memory: 128M, Total max file upload: 128M
Resource folder writeable: Yes
HTTP_HOST: staging.experiencewalesinvenice.org
DOCUMENT_ROOT: /srv/users/serverpilot/apps/stagingwalesinvenice/public
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
thanks for your help
I think you just need to remove the
suppress="true"
attribute - that stops the tag outputting anything.Thanks, but hat hasn't worked unfortunately. I should have said that after the suppressed h1, there's a URL link within a block which isn't suppressed, but I'm getting the same result.
So what does your template look like now?
Hi, it looks like this:
Hi,
Don't know if this will help your larger issue, but am I seeing id="article-embed" twice, the second time with an extra </a> tag?
What value do you have the post path set to on the Settings page?
Thanks John - didn't notice the extra </a> tag - hasn't solved the problem, but well spotted.
Hi Drew - my post path settings are: /blog/{postSlug}
Previously, in my file system I created a /blog/ directory, and placed 'post.php' there - as I initially had 404 errors when trying to postURL link from posts in my Blog section, and this seemed to solve this issue. Don't know if this was the right thing to do, or is the cause of my current problem.
But it's posts created using the new default post template 'perch/templates/blog/posts/post_timeline.html' that are failing to link.
I've a feeling I need to create a new file/page somewhere to handle these posts - but not sure where?
Thanks
Is the issue not that the link isn't being output?
Yes, that's the issue - it's printing to the page <href= >
Ok, so you don't need to create a file - that's not the issue - you don't even have a link yet.
If you add the following to your template, what does it output?
Yes, postURL is present:
I realise I'm having the same issue in my regular post types as well - and it's to do with content contained within Blocks. So postURL, postSlug, authorGivenName - all Blog template variables return empty if they're contained within a Block. Place them outside, and they reference fine.
I need to be be able to link to the postURL from within a block though - is there anything that I can do?
Thanks for your help.
Hi Drew, sorry to hassle - any thoughts on this one? Thanks.
It sounds like you basically need the
scope-parent
option that repeaters use, is that correct?Yes, that's it! Is this currently possible with blocks? I've tried to implement it, but can't get it to work:
I don't think that's implemented currently with blocks. I'll log it as an enhancement request.
Great - it would be a useful enhancement for me anyway.
Thanks for your help.