Error displaying titles

Permalink 1 user found helpful
I'm in the last process of a site and i'm having an issue with displaying correct page titles.

i added a getCollectionName into a custom view.php file for the content block, because i use tony rapid ajax paging block to display the main content of blog pages. i first tried using a content block with a page title attribute, but this was always rendering the page it was on.

then i tried this method, and it's working on ajax loads, but doing something similar when it's loaded with the page teasers add on.
i've written the add on developer, but i'm also reaching to the community to see if anyone has a simple solution, as i really need to wrap up this site.

here is one of the problem pages, as you can see every title on this page reads "blog" instead of actual titles.
http://ladyapples.com/index.php?cID=191...

i've seen a few similar cases, but am unsure if they would help or where i could add the code. here is one similar topic perhaps.
http://www.concrete5.org/community/forums/customizing_c5/get-page-t...

does anyone have a practical workaround? seems like it would be a simple case to crack, but i'm not seeing it quite yet.
thanks in advance.

freestylemovement
View Replies: View Best Answer
freestylemovement replied on at Permalink Reply
freestylemovement
this is the custom content blocks view template:

<?php 
   defined('C5_EXECUTE') or die("Access Denied.");
?>
<h1> <?php echo $page->getCollectionName();
?> </h1>
<?php    $content = $controller->getContent();
   print $content;
?>
freestylemovement replied on at Permalink Reply
freestylemovement
What i noticed is that once the cache is set by visiting a page, the title is stored in that page's cache, and on the blog, and home pages, the correct name carries. although this seems like it could work somewhat, it seems like it could lead to an issue if we do more development later on, as when the cache is cleared each page will have to be visited again to restore the cache?
mhawke replied on at Permalink Reply
mhawke
I would fire off a support request to Tony. The features of the Rapid Ajax add-on indicate that it can grab the page's title. Perhaps Tony can explain how.
freestylemovement replied on at Permalink Reply
freestylemovement
Thanks for the response. I noticed that, but i also have 2 kinds of pages im loading. One type of page has a post date, so it would be trickier to parse the rules from the ajax level vs just including the necessary info per page?
mhawke replied on at Permalink Reply
mhawke
I don't own the add-on so I can't troubleshoot it for you. Perhaps someone who has experience with it can chime in.

Paid add-on include free support. Tony knows his product better than anyone. I would ask him.
freestylemovement replied on at Permalink Reply
freestylemovement
I undertsand, and i would try tony but the issue is even before that on the individual pages that dont correctly display their titles, for example the blog page.
Yeah maybe someone else can chime in. Thanks for writing.
mhawke replied on at Permalink Reply
mhawke
The $page->getCollectionName() is repeatedly pulling 'Blog' as the page name because that's the page you're on. Since you are loading the other page's content without reloading the page, the $page object continues to be 'Blog'. That's why Tony built that feature into his add-on otherwise, you can never know the page title. You'll have to ask him how to do this.
freestylemovement replied on at Permalink Reply
freestylemovement
I see what you mean, the rapid paging is on those pages as well. i tried to turn on the update page title feature, in rapid paging, but the add on only updates the browser title, not the actual page that it pulls. i wrote to tony and hopefully will hear back soon. thanks for your help.
freestylemovement replied on at Permalink Reply
freestylemovement
I've made progress.
if i can just get some syntax help that would be extremely helpful.

so the way to get titles is through a custom template in ajax, but now for the blog entries, i need to differentiate the page types whether to include dates or not. (portfolio won't have dates)

here's the outlined code, could you or someone just help with the formatting, please?

thanks so much.

<?
defined('C5_EXECUTE') or die(_("Access Denied."));  
global $c;
?>
<h1><?= $c->getCollectionName() ?></h1> // title, works good
<p>
<?= $pageType->c->getCollectionTypeHandle()
if {
$pagetype = left_sidebar_blog }
then {
<? php date( 'F j, ', (strtotime($c->getCollectionDatePublic()) ) ) ?>2071
} 
else {nothing}
</p>
// rest is fine
mhawke replied on at Permalink Best Answer Reply
mhawke
Try this (untested):

<?php
defined('C5_EXECUTE') or die("Access Denied.");  
global $c;
?>
<h1><?php echo $c->getCollectionName(); ?></h1> // title, works good
<p>
<?php
$pagetype = $c->getCollectionTypeHandle();
if ($pagetype == 'left_sidebar_blog'){echo " ~ " . date( 'F j, ', (strtotime($c->getCollectionDatePublic())));}
?>
</p>


Try not to use php short codes such as "<?=". Use "<?php echo" instead because I've run across some servers where php short codes are disabled. Also with the rise of XML, browsers are going to start getting confused.
freestylemovement replied on at Permalink Reply
freestylemovement
wow, this totally works, thank you!! 1 step away now..
Tony replied on at Permalink Reply
Tony
hey freestylemovement, I'm hitting that url, but when I click the links the title is correctly changing for me. is this only happening in a certain browser for you? or is it something you just fixed? I took a look in both chrome and firefox, both seem fine.
freestylemovement replied on at Permalink Reply
freestylemovement
hi tony,
ive gotten most of it to work, but now when i use the top menu links (portfolio, blog offerings) there is an extra title that pops up...?

here is the closest thing i could come up with, based on hawk's date navigation edit:

<?php
defined('C5_EXECUTE') or die("Access Denied.");  
global $c;
?>
<?php $pagetype = $c->getCollectionTypeHandle();
   if ($pagetype == 'left_sidebar_blog' , 'left_sidebar_main'){<h1><?php echo $c->getCollectionName(); ?></h1> 
<p>}
<?php
$pagetype = $c->getCollectionTypeHandle();
if ($pagetype == 'left_sidebar_blog'){echo " Posted on " . date('F j, Y, g:i a', (strtotime($c->getCollectionDatePublic())));}
?>
</p>
<?= $innerContent ?>
Tony replied on at Permalink Reply
Tony
well those titles are coming back in the ajax request:
http://ladyapples.com/index.php/tools/packages/tony_rapid_paging/se...

are you sure that those pages aren't of the type "left_sidebar_blog" or "left_sidebar_main"?

if they're not and it's still not working, then try changing the if condition to this:
($pagetype == 'left_sidebar_blog' || $pagetype == 'left_sidebar_blog' 'left_sidebar_main')
freestylemovement replied on at Permalink Reply
freestylemovement
The main pages (portfolio blog) which shouldnt have titles displayed are simply left sidebars.

So in the ajax template, would this be the correct way to make sure only main and blog pages get titles?

<?php
$pagetype = $c->getCollectionTypeHandle();
if ($pagetype == 'left_sidebar_blog''left_sidebar_main')){echo " <h1><?php echo $c->getCollectionName(); ?></h1> " 
?>
<p>
<?php
$pagetype = $c->getCollectionTypeHandle();
if ($pagetype == 'left_sidebar_blog'){echo " Posted on " . date('F j, Y, g:i a', (strtotime($c->getCollectionDatePublic())));}
?>
</p>


Adrien. .::[ ゆ ]::.

> On Jan 14, 2014, at 9:56, concrete5 Community <[email protected]> wrote:
Tony replied on at Permalink Reply
Tony
you're missing the "or" ||... and it doesn't look like you understand how php tags work.

<?php
$pagetype = $c->getCollectionTypeHandle();
if ($pagetype == 'left_sidebar_blog' || $pagetype == 'left_sidebar_main'){ ?> 
    <h1><?php echo $c->getCollectionName(); ?></h1>
<? } ?>
<p>
<?php
$pagetype = $c->getCollectionTypeHandle();
if ($pagetype == 'left_sidebar_blog'){
   echo " Posted on " . date('F j, Y, g:i a', (strtotime($c->getCollectionDatePublic())));
}
?>
</p>