You are here:  » Sitemap converted to Sitelinks page. Create names strip Url?


Sitemap converted to Sitelinks page. Create names strip Url?

Submitted by APZ215 on Wed, 2020-02-12 10:02 in

Hello David

I am trying to create sitelinks / list pages from the sitemap.php

I created/renamed the sitemmap.php to sitelinks.php and mixed up the code a little bit to get a list with links.

Now i want to use the merchant and product name as a link, and not the whole url. Is that possible?

(Example page: https://www.example.com/sitelinks.php)
(Example page: https://www.example.com/sitelinks.php?filename=Cookinglife.csv)

This is how i have it now

https://www.example.com/sitelinks.php?filename=Cookinglife.csv

https://www.example.com/products.php?q=Voorraadpot+bamboe+wit+900+ml

This is what i want (without url, only the name, and if possible without +)

Cookinglife.csv

Voorraadpot bamboe wit 900 ml

And i just cant get it fixed, and cant get the changes made to the ($sitemapBaseHREF.$sitemapHREF.) to stip the urls.

i hope you understand what i mean ;-)

Greetings Arlo

Submitted by support on Wed, 2020-02-12 10:51

Hello Arlo,

You could explode() the link on the "=" character and use the second value in the array with urldecode() to remove the "+" characters (SPACE in a URL) for example:

<?php
  $link 
$sitemapBaseHREF.$sitemapHREF;
  
$parts explode("=",$link);
  print 
"<a href='".$link."'>".urldecode($parts[1])."</a>";
?>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by APZ215 on Wed, 2020-02-12 11:55

Hello David,
- when i place the new code on top in my file nothing changes.
- When i place the code into the code (url and print) where i need the encoded url.. i get: Internal Server Error

Where do i place the code?

<?php
  $link 
$sitemapBaseHREF.$sitemapHREF;
  
$parts explode("=",$link);
  print 
"<a href='".$link."'>".urldecode($parts[1])."</a>";
?>

{link saved} for example where i need to place the code.

I hope you can fix it

Greetings Arlo

Submitted by support on Thu, 2020-02-13 08:44

Hello Arlo,

Where you have this line in your code (2 instances);

print "<a href='".$sitemapBaseHREF.$sitemapHREF."'>".$sitemapBaseHREF.$sitemapHREF."</a>";

...have a go with:

$link = $sitemapBaseHREF.$sitemapHREF;
$parts = explode("=",$link);
print "<a href='".$link."'>".urldecode($parts[1])."</a>";

Cheers,
David.
--
PriceTapestry.com

Submitted by APZ215 on Tue, 2020-02-18 08:17

Hello David,

Hi David, I tried it and it partly works. But with the product links, no list is made and you only see 1 product.

{link saved}

Greetings Arlo

Submitted by support on Tue, 2020-02-18 08:22

Hi Arlo,

Please could you email me the sitelinks.php you have created and I'll take a look at the code in context...

Thanks,
David.
--
PriceTapestry.com