• Welcome to PHPVIBE Forums. Please log in.

[ Video Sharing CMS v4 ] Simple Sitemap script

Started by mio,

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

mioTopic starter

I found a simple php script to generate dynamic sitemap and I've modified it for PhpVibe Video Urls.

1) Create a file called "sitemap.php"

2) Add the code below:

<?php
mysql_connect("localhost", "phpvibe_user", "phpvibe_password") or
    die("Could not connect: " . mysql_error());
mysql_select_db("phpvibe_database");//////////// <  

  $query = mysql_query ( "SELECT  * FROM vibe_videos WHERE pub > 0 ORDER BY `date` DESC" );
  $row = mysql_fetch_assoc ( $query );

 echo '<?xml version="1.0" encoding="utf-8"?>' . "
  ";
  ?>

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <?php
  ############# BEGIN LOOP ############
  do {
  $link = 'http://www.yoursite.com/video/' . $row['id'].'/' .$row['title'].'/';
  $lastmod = $row['date']; 
  $priority = 0.5;
  $changefreq = 'weekly';

  ?>
  <url>
  <loc><?php $input = $link; $patterns = '/ /'; $replacements = '-'; echo preg_replace($patterns, $replacements, $input); ?></loc>
  <lastmod><?php $datetime = new DateTime($lastmod); $result = $datetime->format('Y-m-d\TH:i:sP'); echo $result; ?></lastmod>
  <priority><?=$priority?></priority>
  <changefreq><?=$changefreq?></changefreq>
  </url>
  <?php
  } while ( $row = mysql_fetch_assoc ( $query ) );
  ############# END LOOP ############

  ?>
  </urlset>


3) Edit the file using your website settings (database connection, url)

4) Upload it into your public_html directory

5) Submit your sitemap to google

Enjoy!!

Note: This script works for phpVibe video section only.

  •  

grantj21

Thank you for the share works just fine for me..
  •  

videonavy

Thank you for sharing this script.

I received this error when I implemented it:

QuoteFatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (all_time) at position 0 (a): The timezone could not be found in the database' in /home/xxxxxxx/public_html/vibe-sitemap.php:25 Stack trace: #0 /home/xxxxxx/public_html/vibe-sitemap.php(25): DateTime->__construct('all_time') #1 {main} thrown in /home/xxxxxx/public_html/vibe-sitemap.php on line 25
  •  

OliverJ

Works great but can you make a Video Sitemap ? i dont know if google index the videos correctly.
  •  

PHPVibe A.

I feel like I need to warn of this: Right now you can only place local files in video sitemap, if you place youtube videos or other you may get banned by google (changed rules).

mioTopic starter

@videonavy: Try to remove:

$lastmod = $row['date']; 

  <lastmod><?php $datetime = new DateTime($lastmod); $result = $datetime->format('Y-m-d\TH:i:sP'); echo $result; ?></lastmod>


According to google, lastmod tag is optional.

@Alexander:Where did you hear that?
  •  

PHPVibe A.


mioTopic starter

Ok, I trust you but I think ban may be for duplicate content and not for the sitemap itself.

In my opinon:

It's important publish no more of 10-20 daily videos.
Change title and description for each video published.
  •  

videonavy

  •  

mioTopic starter

  •  

PHPVibe A.

Quote from: vivimor on
Ok, I trust you but I think ban may be for duplicate content and not for the sitemap itself.

In my opinon:

It's important publish no more of 10-20 daily videos.
Change title and description for each video published.

It's an healthy way.

epycost

#11
Salut, nu poti sa updatezi sitemapul de la versiunea mai veche pt 3.6 ?
<?php  error_reporting(0);
//Vital file include
include("vibe_config.php");
$pageNumber = MK_Request::getQuery('page', 1);	
$pagi_url = $site_url.'videomap.php?page=';
$BrowsePerPage = 1500;
$numberofresults = dbcount("*","videos");
$mapcache = "map-".$pageNumber;
$limit = 'LIMIT ' .($pageNumber - 1) * $BrowsePerPage .',' .$BrowsePerPage; 
$vbox_result ="select id,title from videos ORDER BY id DESC $limit";
$content = '<ul style="margin:10px 20px;">';
if ($cboxes = $dbi->query($vbox_result,86400,$mapcache)) {
foreach ($cboxes as $video) {
		$content .= '<li>
			'.$video["id"].'. <a href="'.$site_url.'video/'.$video["id"].'/'.seo_clean_url($video["title"]) .'/" title="'.html_entity_decode(stripslashes($video["title"])).'">'.html_entity_decode(stripslashes($video["title"])).'</a>
			</li>';
}
}
$content .='</ul>';
$content .='<div class="clear"></div>';
$a = new pagination;	
$a->set_current($pageNumber);
$a->set_first_page(true);
$a->set_pages_items(12);
$a->set_per_page($BrowsePerPage);
$a->set_values($numberofresults);
$content_title = "Videos (".$numberofresults.")";
$seo_title = "Videos Map Page ".$pageNumber;
include_once("tpl/header.php");     
include_once("tpl/content.tpl.php");
echo '<br style="clear:both;"/>';
$a->show_pages($pagi_url);
include_once("tpl/footer.php");
MK_MySQL::disconnect();
?>
  •  

PHPVibe A.

Nu, asta e ptr 3.1 si sunt platforme complet diferite.

epycost

#13
OK sunt platforme diferite... dar cand faceti un sitemap pt ultima versiune? era vorba pt 3.5 ... acu e 3.6 , dar sitemapul nu e facut inca.
http://www.phprevolution.com/forum/troubleshooting-issues/3-4-beta-sitemap-module/msg13771/#msg13771
  •  

PHPVibe A.

Sitemap-ul se face cam in 2 minute gen aici http://www.phprevolution.com/forum/troubleshooting-issues/how-to-put-a-player-in-channel-pages/msg17990/#msg17990
Insa Mario spune ca in cazul website-urile pe PHPVibe nu prea e ok cu sitemap din experienta sa.

xda

  •  

PHPVibe A.


conghandang

That sitemap is up not good for use? how I can create a good site map for my website?

Thanks!
  •  

Similar topics (7)