Jump to content

Please read the Forum Rules before posting.

Photo

Downloads on portal page


  • Please log in to reply
3 replies to this topic

#1 shareware

shareware

    New to Bible Support

  • Veterans
  • Pip
  • 2 posts
Offline

Posted 25 August 2011 - 11:31 AM

Hi, I run a shareware download website and found your site when doing a search for sites running ipboard. I tried pming the admin but the mailbox was full.

How did you get your most recently downloaded files to show on the main portal page? Also, how do allow users to post youtube videos in their profile? And one more, how are you dividing out the mysword files into their own box on the downloads portal? I can't find anything like this for sale anywhere.

Thank you in advance,

Mark

#2 Josh Bond

Josh Bond

    Administrator

  • Administrators
  • PipPipPipPipPip
  • 2,882 posts
  • LocationGallatin, TN
Offline

Posted 25 August 2011 - 12:39 PM

The YouTube functionality is just a free hook: http://community.inv...eos-in-profile/

I wrote the most recent files downloaded code for IP.Content not Portal. This may work with Portal, but I'm not sure. Create a custom block, raw php and add the code below.. You'll need to call this block from your main index page or from the Frontpage template. I call it from the frontpage template show it only shows on the main page, not other pages that use the index template.


$hostname='localhost'; // specify host, i.e. 'localhost'
$user='username'; //  specify username
$pass='password'; // specify password
$dbase='dbname'; // specify database name
$connection = mysql_connect("$hostname" , "$user" , "$pass")
or die ("Can't connect to MySQL");
$db = mysql_select_db($dbase , $connection) or die ("Can't select database.");
 
 
date_default_timezone_set("US/Central");
echo "<h4 class='maintitle'>{$title}</h4>"; //tell php to use central time
 
echo "<div class='article_sidebar2'>"; //get the formatting right using same div's as sidebar
echo "<div class='general_box'>"; //get the formatting right using same div's as sidebar
 
 
 
echo "<ul class=\\"hfeed\\">"; //get the formatting right using same div's as sidebar
//echo "<span style='font-size: 15px;'>";
 
//get the last 6 download file id's and timestamp from the downloads_downloads table. Change 6 to how many you want to show
$query = "SELECT dfid, dtime FROM downloads_downloads ORDER BY did DESC limit 6";
$dlresult = mysql_query( $query );
 
$i=0;
$num = mysql_num_rows ($dlresult); \\number of files found, which will be 6 based on the sql statement above
while ($i < $num) {  //start our loop to show the files, loop 6 times starting with the counter at 0
 
$dfid= mysql_result($dlresult,$i,"dfid"); //get the file number
$dtime= mysql_result($dlresult,$i,"dtime"); //get the time stamp
 
//Query downloads_files table, get actual filename and file url  from file #
$query2 = "SELECT file_name, file_downloads, file_name_furl FROM downloads_files WHERE file_id = '$dfid'";
$dlresult2 = mysql_query( $query2 ); //name the query something different than the one above.
 
$dlfile_name= mysql_result($dlresult2,0,"file_name"); // get the filename text
$dlfile_name_furl= mysql_result($dlresult2,0,"file_name_furl"); //get the filename furl
//$dlfile_downloads= mysql_result($dlresult2,0,"file_downloads"); //get # of file downloads
//$dlfile_cat= mysql_result($dlresult2,0,"file_cat"); //get the file category id.
 
// to test whether $i is odd to show light/dark blue alternating rows for ease of reading
if( $odd = $i%2 )
{
 
	echo "<li class=\\"hentry row1\\">"; //make the row lighter blue based on css
}
else
{
 
   	echo "<li class=\\"hentry row2 altrow\\">"; //make the row darker blue based on css
  
}
 
 
//assemble and display file url - change this URL to your board name and your DL portal directory name
echo "<a href=\\"http://www.biblesupport.com/e-sword-downloads/file/$dfid-$dlfile_name_furl\\">$dlfile_name</a>, ";
 
 
 
echo "<span class='date'>";
 
 
//set the date format, class, formatting
echo date('g:i A', $dtime);
//echo " - (Downloads: $dlfile_downloads)";
echo "</span>";
echo "<br />";  //line break so the files don't run together
 
echo "</li>"; //close the li opening above
++$i; //increment counter
}
 
//Begin section to see how many files downloaded today
$dl_count_today = strtotime("midnight today"); //Store unix timestamp in this variable.
$query3 = "SELECT dtime FROM downloads_downloads WHERE dtime >= '$dl_count_today'"; //find all files downloaded from midnight on.
$dlresult3 = mysql_query( $query3 );
$num = mysql_num_rows ($dlresult3); // $num is the number of files downloaded today.
 
//Begin section to see how many new members joined today
$newmem_count_today = strtotime("midnight today"); //Store unix timesteamp in this variable
$query3 = "SELECT joined FROM members WHERE joined >= '$newmem_count_today'";  //find all new members from midnight on
$dlresult3 = mysql_query( $query3 );
$num3 = mysql_num_rows ($dlresult3); //$num is the number of new members today.
 
 
echo "<span class='date_downloads_ipcontent' style=\\"display: block; text-align: right; padding-top: 10px; padding-bottom: 0px;\\">"; \\date_downloads_ipcontent is a custom style I added to the stylesheet
 
echo "New Members Today: $num3   |   Downloads Today: $num   |   ";
echo "<a href=\\"http://www.biblesupport.com/page/last-100-e-sword-downloads.php\\">Last 100 Downloads</a>"; \\Change this url to your own. Must also create a page in Ip.content to how the last 100 downloads, otherwise remove this echo statement.
echo "<br><a href=\\"http://www.biblesupport.com/index.php?app=members&section=online&module=online&sort_key=click&sort_order=asc&show_mem=all&st=0\\"><strong>Spy: </strong>What are other people doing right now?</a>"; //Shows what other users are doing right now.
 
//echo "<p class=\\"article_sidebar\\">Click here for</p>";
echo "</span></ul></div></div>"; //close the elements opened above
mysql_close(); //close db connection


I made the MySword and Official e-Sword boxes on the Download page by editing the DownloadsPortal template under the Download Manager category. These edits are pretty easy html edits. Add this html to where you want the boxes to appear.

The code to insert is between the ---. Don't include the dashes. The code above and below the dashes is the existing code to give you something searchable to locate the insertion point (assuming you want to insert it at the same place I did, otherwise ignore everything above/below the dashes).

You'll obviously have to change the URLs and box names, and delete that second box if you don't want it. Also, the category_rows numbers will need to be adjusted for your site and it may not necessarily be the category number (isn't that nice? May take some trial and error to find the #). The subcategories numbers will stay the same. If you try this code without any subcategories inside your main category, the Downloads portal will show a php error. If you don't care about showing the number of files in each subcategory, just delete the file_count_right spans and the references to the categories.


<if test="indexsubcategories:|:is_array($data['subcategories']) AND count($data['subcategories'])">
<a href='#' class='cat_toggle'>{$this->lang->words['toggle']}</a>
</if>
</li>
</foreach>
</ul>
 
</div>
 
---
 
<h2 class='maintitle'>MySword Categories</h2>
<div class='general_box'>
<ul id='idm_categories'>
 
<li class>
<span class='file_count right'>
{parse format_number="$category_rows[16]['subcategories'][0]['cfileinfo']['total_files']"}
</span>
<a href="http://www.biblesupport.com/files/category/27-bibles/" title="View Category">Bibles</a>
</li>
 
<li class>
<span class='file_count right'>
{parse format_number="$category_rows[16]['subcategories'][1]['cfileinfo']['total_files']"}
</span>
<a href="http://www.biblesupport.com/files/category/28-commentaries/" title="View Category">Commentaries</a>
</li>
 
<li class>
<span class='file_count right'>
{parse format_number="$category_rows[16]['subcategories'][2]['cfileinfo']['total_files']"}
</span>
<a href="http://www.biblesupport.com/files/category/29-dictionaries/" title="View Category">Dictionaries</a>
</li>
 
<li class>
<span class='file_count right'>
{parse format_number="$category_rows[16]['subcategories'][3]['cfileinfo']['total_files']"}
</span>
<a href="http://www.biblesupport.com/files/category/30-books/" title="View Category">Books</a>
</li>
 
<li class>
<span class='file_count right'>
{parse format_number="$category_rows[16]['subcategories'][4]['cfileinfo']['total_files']"}
</span>
<a href="http://www.biblesupport.com/files/category/31-graphicsmaps/" title="View Category">Graphics/Maps</a>
</li>
 
<li class>
<span class='file_count right'>
{parse format_number="$category_rows[16]['subcategories'][5]['cfileinfo']['total_files']"}
</span>
<a href="http://www.biblesupport.com/files/category/32-devotionals/" title="View Category">Devotionals</a>
</li>
 
</ul>
</div>
 
<h2 class='maintitle'>Official e-Sword</h2>
<div class='general_box'>
<ul id='idm_categories'>
 
<li class>
 
<a href="http://www.e-sword.net">Download e-Sword</a>
</li>
 
<li class>
 
<a href="http://www.estudysource.com">Premium Modules</a>
</li>
</div>
 
 
---
</div>


#3 shareware

shareware

    New to Bible Support

  • Veterans
  • Pip
  • 2 posts
Offline

Posted 25 August 2011 - 04:48 PM

Thank you so very much!!

Could I ask one more thing, how do you display messages in the file listing template that change with the category the file is in? Theres just no docs on this.

Thank you once again!

Mark

#4 Josh Bond

Josh Bond

    Administrator

  • Administrators
  • PipPipPipPipPip
  • 2,882 posts
  • LocationGallatin, TN
Offline

Posted 25 August 2011 - 06:30 PM

Here's the basic idea of how to do it using IPBoard's scripting. The numbers in each array are category numbers. So, if the "if" statement is true (the $category's cid matches one of the numbers in the array), then everything inside the "if" tags is executed.



<if test="in_array( $category['cid'], array(2,3,4,5,6,7,8,9,10,11,12,13,14,33,34,35,36,38) )">
<span style="font-size:16px;color: #528F6C;">
<strong>e-Sword 9+ Module Download:</strong><br /></span></if>
 
<if test="in_array( $category['cid'], array(15,16,17,18,19,20,21,22,23,24,25,37) )">
<span style="font-size:16px;color: #528F6C;">
<strong>e-Sword 8.x Module Download:</strong><br /></span></if>
 
<if test="in_array( $category['cid'], array(27,28,29,30,31,32) )">
<span style="font-size:16px;color: #528F6C;">
<strong>MySword (Mobile) Module Download:</strong><br /></span></if>
 
<if test="in_array( $category['cid'], array(40,41,42,43) )">
<span style="font-size:16px;color: #528F6C;">
<strong>Pocket e-Sword Module Download:</strong><br /></span></if>

Virtually anything can be scripted. You can check to see if a user is logged in, and if so, do something.
 
 
<if test="searchlinks:|:$this->memberData['member_id']">
user is logged in so do something here
</if>
<else>
user is not logged in, so do something or leave off the else tags to do nothing
</else>

Another way of testing if a user is NOT logged in:


<if test="in_array( $this->memberData['member_group_id'], array('2') )">
member not logged in, do something
</if>

Member_id is a field from the database, as is member_group_id. For Member_group_id I think 2 is not logged in. 3 is a normal user. 4 is an admin. So you could look at the database, find the gender field, and test if the member is male, female, or unspecified. And execute code accordingly. You can script virtually anything using IPB's internal system. It's pretty flexible.

These are the major root level variables.

$this->registry;
$this->DB;
$this->settings;
$this->request;
$this->lang;
$this->member;
$this->memberData;
$this->cache;
$this->caches;

To find what variables are available where your working, you can print the variables within the root variable:
 
print "<textarea cols='50' rows='20'>";
print_r( $this->caches );
print "</textarea>";

or if your working in parts of IP.Content, you can do this instead:

<php>$stats = $this->registry->cache()->getCache('idm_stats');$output = print_r($stats, true);</php>{$output}
And your right, none of this is documented in any central location. IPBoard is overall the best community software available, in my opinion. Certainly the most powerful and flexible with the fewest plugins required. IP.Content is so powerful IPB has trouble describing what IP.Content actually does and it took me a while to understand what it's truly capable of. This website doesn't come close to exploiting IP Content's true power (just not a need for it), but the ability to create custom databases is amazing.

I've taken over a Drupal website, and oh my goodness. Hundreds and hundreds of plugins called "blocks". A block for everything. Someone wants a picture in the forums, well that's 3-4 blocks of add-ons (usually third party). You want a poll, well there's 5 block add-ons. You want to track the number of downloads per resource (node? Oh you gotta install 2-3 blocks for that. Crazy!? That should be built-in. I don't know how you even begin to maintain that over time, keeping track of versions and what's been updated. Then what if there is no update by the volunteer person who made the block, you have to find another block replacement and hope someone has made something?

That's the upside and downside to IPBoard. You can do all kinds of things that other software requires plugins for. But to achieve the level of scripting and customization that IPB has (especially in IP.Content), there's a learning curve. Just remember to make all changes to templates or css, not at the php file level. File edits are very bad because you lose them when you upgrade! Good luck with it! if you have any more questions, just PM me. I cleaned out my box and increased my message quota. :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users




Similar Topics



Latest Blogs