I want to create a custom form that will list out a documents from the PhocaDownload extension. However, I want it to list the documents for a user whose JomSocial profile is currently being viewed on the front end of the site. So, if I am on Person1's profile page, I will see the list of documents that have been uploaded by Person1. If I visit Person3's profile page, their docs are the ones I should see.
The URL for viewing a profile page looks like:
index.php?option=com_community&view=profile&userid=44
I know how to do exactly what I want, including making the document names link to the downloads. What I need to know is how can I pull the 'userid' from the above URL into CF to use it in a query?
Thanks!!!
The URL for viewing a profile page looks like:
index.php?option=com_community&view=profile&userid=44
I know how to do exactly what I want, including making the document names link to the downloads. What I need to know is how can I pull the 'userid' from the above URL into CF to use it in a query?
Thanks!!!
Well, you can ignore this post. I figured it out!!
Here's what I did (in case it helps anyone in the future). I used a DB Multi Record Loader action in the OnLoad event. In the record loader, I used the following in the WHERE field:
Then, I used a Custom Code action to list out the document names from the results returned above. Each document is hyperlinked directly to the download. Could NOT have done it without CF!!! 😀
Here's what I did (in case it helps anyone in the future). I used a DB Multi Record Loader action in the OnLoad event. In the record loader, I used the following in the WHERE field:
`published` = 1 AND `approved` = 1 AND `owner_id` = '<?php
$url=$_SERVER['REQUEST_URI'];
parse_str($url);
echo $userid;
?>'
Then, I used a Custom Code action to list out the document names from the results returned above. Each document is hyperlinked directly to the download. Could NOT have done it without CF!!! 😀
As a follow-up, the prior post would only work without SEF URL's turned on. In order to accommodate SEF URL's, I had to change the PHP in the WHERE clause to:
This worked for me, and will return the userID of the JomSocial profile being viewed.
<?php
$url=$_SERVER['REQUEST_URI'];
$findbegin = 'jomsocial/';
$findend = '-';
$pos_begin = strpos($url, $findbegin);
$pos_end = strpos($url, $findend);
$cut_begin = $pos_begin + 10;
$cut_length = $pos_end - $cut_begin;
echo substr($url, $cut_begin, $cut_length);
?>
This worked for me, and will return the userID of the JomSocial profile being viewed.
Hi Rick,
Well done.
There is a Joomla! JURI class that helps with parsing URLs, though I'm never sure if it sees the 'raw' URL or the SEF version; must experiment one day to find out.
Bob
Well done.
There is a Joomla! JURI class that helps with parsing URLs, though I'm never sure if it sees the 'raw' URL or the SEF version; must experiment one day to find out.
Bob
Bob,
I looked further into your suggestion, and was able to simplify my code a LOT. Now, to get the userID of the JomSocial profile being displayed, I use this:
Much simpler than the other code, which broke immediately upon me switching to URL rewriting (because "jomsocial" was removed from the URL). With this form displaying in a module only available on JomSocial pages, it works perfectly.
Thank you SO much for the suggestion!!! Teach a man to fish, I guess... :wink:
Rick
I looked further into your suggestion, and was able to simplify my code a LOT. Now, to get the userID of the JomSocial profile being displayed, I use this:
$currenturl = JURI::current();
$this_user = ereg_replace("[^0-9]", "",$currenturl);
Much simpler than the other code, which broke immediately upon me switching to URL rewriting (because "jomsocial" was removed from the URL). With this form displaying in a module only available on JomSocial pages, it works perfectly.
Thank you SO much for the suggestion!!! Teach a man to fish, I guess... :wink:
Rick
This topic is locked and no more replies can be posted.