Forum

Thread tagged as: Problem, Blog

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

David Shepherd

David Shepherd 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

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.

Drew McLellan

Drew McLellan 2638 points
Perch Support

So what does your template look like now?

Hi, it 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" order="1" />
    </a>
  </h1>

  <perch:blog id="intro" type="textarea" editor="redactor" markdown="false" html="true" size="autowidth" label="Leave this empty" order="1"/>

    <perch:blocks>

    <perch:block type="bl-writing" label="Writing">
      <div class="tl-entry tl-writing">
        <perch:blog id="writing" type="textarea" editor="redactor" markdown="false" html="true" size="autowidth" label="Your Content" suppress="true" order="1"/>
        <a href="<perch:blog id="postURL" type="hidden" rel="bookmark" class="p-name"/>" >
          <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-embed" type="text" html="true" label="Embed code for Vimeo goes here" order="1" />
        <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">
          <p><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" /></p>
          <div class="external-links">
            <a href="<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." html="true" order="1"/>" data-rel="lightcase">
              <img src="assets/icons/icon_expand.png" alt="Icon - open lightbox" title="Open this article in a lightbox"/>
              View here
            </a>

            <a href="<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." html="true" order="1"/>" target="_blank">
              <img src="assets/icons/icon_expand.png" alt="Icon - open lightbox" title="Open this article in a lightbox"/>
              View here
            </a>
          </div>
        </a>
      </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>

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?

Drew McLellan

Drew McLellan 2638 points
Perch Support

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

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is the issue not that the link isn't being output?

Yes, that's the issue - it's printing to the page <href= >

Drew McLellan

Drew McLellan 2638 points
Perch Support

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?

<perch:showall />

Yes, postURL is present:

ID  Value
perch_page_path /index.php
month-selector  feb
_blocks 
Array
(
    [0] => Array
        (
            [video-embed] => 
            [video-descr] => Array
                (
                    [raw] => 
content

                    [processed] => 
content

                )

            [_block_type] => bl-video
            [_block_id] => nnrqnp
            [_block_index] => 0
        )

)
categories  
itemID  11
postID  11
postTitle   Press Launch - Vimeo
postSlug    2015-05-03-press-launch-vimeo
postDateTime    2015-05-03 11:03:00
postDescRaw 
postDescHTML    
postDynamicFields   {"month-selector":"feb","_blocks":[{"video-embed":"","video-descr":{"raw":"An edited version of the{...}
postTags    
postStatus  Published
authorID    3
sectionID   2
postCommentCount    0
postImportID    
postLegacyURL   
postAllowComments   1
postTemplate    posts/post_timeline.html
sortval 2015-05-03 11:03:00
paging  false
total   5
number_of_pages 1
total_pages 1
per_page    50
current_page    1
lower_bound 1
upper_bound 5
prev_url    
next_url    
prev_page_number    
next_page_number    
perch_month-selector    feb
perch__blocks   
Array
(
    [0] => Array
        (
            [video-embed] => 
            [video-descr] => Array
                (
                    [raw] => 
content


                    [processed] => 
content


                )

            [_block_type] => bl-video
            [_block_id] => nnrqnp
            [_block_index] => 0
        )

)
perch_categories    
authorGivenName Anne
authorFamilyName    Siegel
authorEmail anne@ffotogallery.oeg
authorPostCount 49
authorSlug  anne-siegel
authorImportRef 
authorDynamicFields 
postURL /blog/2015-05-03-press-launch-vimeo
perch_item_first    true
perch_item_zero_index   0
perch_item_index    1
perch_item_rev_index    5
perch_item_rev_zero_index   4
perch_item_odd  
perch_item_count    5

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.

Drew McLellan

Drew McLellan 2638 points
Perch Support

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:


<perch:block type="bl-writing" label="Writing" scope-parent="true"> <div class="tl-entry tl-writing"> <perch:blog id="writing" type="textarea" editor="redactor" markdown="false" html="true" size="xl" label="Your Content" suppress="true" order="1"/> <a href="<perch:blog id="parent.postURL" type="hidden" rel="bookmark" class="p-name"/>" > <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>
Drew McLellan

Drew McLellan 2638 points
Perch Support

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.