Profile page tweek

Permalink 2 users found helpful
Does anyone know how to list the pages belonging to a certain person? I want to list the pages belonging to a person on their profile page. It seems like this should be something that the core has built in but I cant find it.

Thanks.

tallacman
 
tallacman replied on at Permalink Reply
tallacman
So this will be a page list block that displays the pages belonging to a person. The code I found:

$pl->filterByUserID($userID)

Looks promising but I have not successfully got it to work.
jordanlev replied on at Permalink Reply
jordanlev
What specifically have you tried that didn't work? Or do you not know where exactly to put that piece of code? I haven't done this myself but if you give more details I may be able to help.

-Jordan
tallacman replied on at Permalink Reply
tallacman
Jordan,

You own the page at :http://allkleen.com/index.php/archives/event-decor/uber_florist1/...

If you login and go to you profile:http://allkleen.com/index.php/profile...

You will see your page listed on the bottom of the page list block in the main section. However, it lists all the pages of the type "vendor" and I just want it to display your page; pages you own as assigned in the attributes.

user: jordan
passw: jordan

thanks!
jordanlev replied on at Permalink Reply
jordanlev
Got it -- thanks for setting that up. I am wondering if you've actually tried putting that line of code in anywhere, and it's just not doing anything, or if you don't know where to put it at all?
tallacman replied on at Permalink Reply
tallacman
I don't know where to put it. I have this custom template:

<?php
defined('C5_EXECUTE') or die(_("Access Denied."));
$textHelper = Loader::helper("text");
// now that we're in the specialized content file for this block type,
// we'll include this block type's class, and pass the block to it, and get
// the content

if (count($cArray) > 0) { ?>
<div class="ccm-page-list">

<?php
for ($i = 0; $i < count($cArray); $i++ ) {
$cobj = $cArray[$i];
$title = $cobj->getCollectionName(); ?>

<h3 class="ccm-page-list-title stev-page-view"><a href="<?php echo $nh->getLinkToCollection($cobj)?>"><?php echo $title?></a></h3>


<!-- this prints the page description -->
<div class="ccm-page-list-description">
<?php
if(!$controller->truncateSummaries){
echo $cobj->getCollectionDescription();
}else{
echo $textHelper->shorten($cobj->getCollectionDescription(),$controller->truncateChars);
}
?>
</div>
<!-- END this prints the page description -->

<?php }
?>
</div>
<?php }
?>

Which is just the regular view.php with some needless (for my needs) code removed.
jordanlev replied on at Permalink Reply
jordanlev
Okay, try this:

Copy the /concrete/blocks/page_list/controller.php file to /blocks/page_list/controller.php (if you don't already have a "page_list" directory in your site's blocks directory, create it).

Open that copied file, and find this line of code:
$columns = $db->MetaColumns(CollectionAttributeKey::getIndexedSearchTable());

Now, directly ABOVE that line of code, paste this:
//BEGIN CUSTOM CODE -- Filter by current user id if "vendor" page type is selected (so that profile pages only show pages owned by the currently-logged-in vendor)
$vendor_ctID = $db->GetOne('SELECT ctID FROM PageTypes WHERE ctHandle = ?', array('vendor'));
if ($row['ctID'] == $vendor_ctID) {
   $u = new User();
   $pl->filterByUserID($u->uID);
}
//END CUSTOM CODE


(ignore the "<?php" and "?>" in the code sample -- those are automatically inserted by the forum and should not be copied/pasted).

Now whenever you place a page list and choose to only show page types of "Vendor", it will always filter them by the currently-logged-in user. The downside to this is that you can't turn it on or off -- so you won't be able to show ALL vendor pages. To work around this would require some more complicated hackery, so hopefully it's not needed.

Let me know if that works.

-Jordan
tallacman replied on at Permalink Reply 2 Attachments
tallacman
Joran,

Im logged in as you and I can still see all the pages. Attached is my contoller.php I've modified. I've also attached an image of my directory. I am using the stev_view.php as a custom view.
jordanlev replied on at Permalink Reply
jordanlev
Rename that "controller copy.php" file to just "controller.php"
tallacman replied on at Permalink Reply
tallacman
{oops}

Parse error: syntax error, unexpected T_VARIABLE in /home/tallacman/allkleen.com/blocks/page_list/controller.php on line 105

which is:

$vendor_ctID = $db->GetOne('SELECT ctID FROM PageTypes WHERE ctHandle = ?', array('vendor'));
jordanlev replied on at Permalink Best Answer Reply 1 Attachment
jordanlev
Weird -- it works fine for me. Perhaps copying and pasting from the forum messed up the characters somehow (if we have different encodings in our text editors that might happen).

Try using the attached file instead (just make sure you remove the ".txt" from the end -- it should just be "controller.php")
tallacman replied on at Permalink Reply
tallacman
Woohoo! That works! Thanks. Can I buy you a beer?
jordanlev replied on at Permalink Reply
jordanlev
Absolutely! Next time you're in Portland, give me a ring :)