13 replies
Hi all.

I currently have a plugin which takes an input of keywords in txt format, then creates a .xml sitemap for each keyword.

In the sitemap there are 3 variables:

<loc>
<date>
<keyword>

I dont want it to create the

<date>
<keyword>

variable which is fine, I know how to do that.

But later on the plugin requires the <keyword> varibale as it uses this variable to post 50 random links at the end of each page.

This is the code used for that:

}
function get_footer_links()
{
$links = '';
$file = get_option('siteurl').'/sitemap.xml'; // Keyword-URL Filename
$xmlStr = file_get_contents($file);
$xmlObj = simplexml_load_string($xmlStr);
$arrXml = wsp_sfvp_objectsIntoArray($xmlObj);
$counter = 0;
if(is_array($arrXml) && count($arrXml)>0)
{
foreach($arrXml as $arr)
{
if(is_array($arr) && count($arr)>0)
{
shuffle($arr);
foreach($arr as $row)
{
$links .= "<a href='".$row['loc']."' target='_blank'>".$row['keyword']."</a><br/>";

$counter++;
if($counter>50) break;


What i would like, is for the [keyword] varibale to be taken from the URL.. so they sitemap <loc> would be www.sitename.com/key-word-1

I want the plugin to fill [keyword] with key word 1.

It will have to bascially rememove everything before the page title, and then remove '-' and insert a space.

I am hoping this can be done by modifiying the above code.

Could could anyone help me out with this?
#complex #issue #php
  • Profile picture of the author strangerstudios
    Not exactly sure what you are trying to do, but some reading that should help:

    to split up $_SERVER['REQUEST_URI'])
    PHP: pathinfo - Manual

    to understand what $_SERVER['REQUEST_URI'] is:
    PHP: $_SERVER - Manual

    to replace -'s with spaces:
    PHP: str_replace - Manual

    using mod rewrite to redirect /(.*) to index.php?keyword=$1
    URL Rewriting Guide - Apache HTTP Server

    Also, you might already know, but to pass a "parameter" to a PHP script add ?variable=value to the end of the URL. Or ?var1=1&var2=2 (use ? for first var and & between the others)

    Then you can grab that variable from $_GET['variable'] or $_REQUEST['variable']

    Good luck.
    {{ DiscussionBoard.errors[5778409].message }}
  • Profile picture of the author Craftisy
    what are you exactly trying to do?
    {{ DiscussionBoard.errors[5779063].message }}
  • Profile picture of the author Adam Smith
    Thanks StrangerStudio - But I dont know to much about PHP myself.. the plugin was created for me but the developed has stopped answering my emails

    I am trying to change the plugin so it that the 50 random links are taken from 50 random Keywords and URL's in the sitemap.xml file.

    At the moment the 50 random Keywords are taken from a variable <keyword> in the sitemap but when I submit the sitemap to google it shows as an error as the tag <keyword> is not supported.

    You can see an example of the current site map here:

    http://www.bestconversecoupons.com/sitemap.xml

    As you can see <keyword> is the same as the /pagename which comes after Converse Coupons so really there is no need to have <keyword> as I could get the keyword from the <loc>... I just need a way to modify the above code so that it doesnt take the keyword from <keyword> variable, but from the URL.

    Hope that makes sense?
    {{ DiscussionBoard.errors[5779286].message }}
    • Profile picture of the author kdm5157
      I have 2 questions.

      1) Do you know what get_option('siteurl') gives you? does it include the http? does it include www? I tried to put examples but I only have a few posts and I can't put what it considers "links" until after 50

      2) Did you pay your developer? An honest & quality developer should reply even if nothing but to say "I can't provide help until Friday" or something. I know I would! I know that doesn't help your situation, I just am always amazed at how many developers don't maintain core business integrity values!


      Great thing is - you already have the algorithm:

      1) get the URL - from $row['loc']
      2) strip out the URL - hopefully from get_option('siteurl')
      3) replace - with space

      It should be easy to modify, I'm just a little hesitant to outright give that to you. I'm kind of new to the "forum" atmosphere and while I love to help, I'd hate to be taken advantage of :-/
      {{ DiscussionBoard.errors[5780109].message }}
  • Profile picture of the author Adam Smith
    Hi KDM,

    I dont know what get_option)'siteurl') gives me unfortunately

    I do have a little understanding of HTML but none of PHP.. which sucks!

    An example of a page where the 50 random links are outputted is:

    Converse Coupons

    And yes I paid the developer on Odesk... he was great to start with... developed my first plugin for me fine, and was always quick to reply.

    Again I hired him for this project, and everything was fine. I thought the plugin was finished as I hadnt uploaded a sitemap and saw the error. When I noticed that I emailed him several times and messaged him on Odesk, but no reply

    I appreciate your help KDM, and I appologise for others taking advantage - this forum is a great place to extend your knowledge... what areas of IM are you interested in? Maybe I could help develop your knowledge of other areas if you are able to help me with this issue?
    {{ DiscussionBoard.errors[5780273].message }}
  • Profile picture of the author kdm5157
    I feel I could definitely help.

    I'm a Web Developer by trade so I build web sites and web systems. I'm a coder :-P I also teach Web Development and Business Application Development at a local University. Sad thing is I've only had limited exposure to IM. I understand all of the concepts - I know the details but I've never been able to take that leap or get anything started with any type of monetization. I know it can be done but I've yet to do it!

    Sadly, I find myself with time but low funds. I can build sites for clients but the client budgets get lower and lower while their expectations and requirements get higher and larger! I am to the point where I'm filling up my time with jobs that don't truly pay for what I feel my skills are worth. Such is life I guess...

    But anyway, I wish I could PM and I'd send you a message, but I'm still a newbie so they won't let me. The past few days I've been thinking that what I truly need is a mentor or someone who can share what they've done. I hate to purchase such a thing cause money is the main issue ha! I don't want to spend it :-/

    But anyway, I don't mind helping at all. Is that site you sent the actual site you're using or are you mimicking that strategy?
    {{ DiscussionBoard.errors[5780555].message }}
  • Profile picture of the author HyperSpace2012
    $links .= "<a href='".$row['loc']."' target='_blank'>".str_replace('-',' ', $row['keyword'])."</a><br/>";

    I think that's what you were talking about but I'm not sure but it will replace the '-'.

    I'm not sure if the issue is really complex but it's kind of hard to follow what you are looking for. Try showing an example of the data you have, and then after the data that you want.
    {{ DiscussionBoard.errors[5782483].message }}
  • Profile picture of the author Earnie Boyd
    The domain/sitemap.xml has a required specified field set as defined at sitemaps.org/protocol.html and keyword isn't one of them which is why Google complained to you. You may need to replace the exiting developer with a contractor.
    Signature
    {{ DiscussionBoard.errors[5787447].message }}
  • Profile picture of the author Adam Smith
    Thanks KDM - that is the actual site where the plugin is working... Would you mind me PM'ing you?

    Thanks Earnie, I think thats the way I need to go. I know the work needed isnt massive, and infact for someone who knows PHP it is probably only a few lines to change.

    Would anyone be interested in doing this work for me?

    Please PM me with a price, or email me - adam [at] iphone5cases [dot] com
    {{ DiscussionBoard.errors[5793565].message }}
    • Profile picture of the author kdm5157
      Hey Adam - sadly, I can't PM yet cause I'm below the 50 post requirement :-/

      Anyway - email me - same name as here, but gmail.com. I'll be glad to help with your PHP issues. I think it won't take long.

      I tried emailing the address you posted and it got bounced back.
      {{ DiscussionBoard.errors[5793738].message }}
  • Profile picture of the author Adam Smith
    Hey kdm... I just emailed you. Hopefully you will recieve it
    {{ DiscussionBoard.errors[5793937].message }}
  • Profile picture of the author jmel570
    Hey man, did you get this resolved? I would also like to know how to resolve this issue.
    {{ DiscussionBoard.errors[5795008].message }}
  • Profile picture of the author Big Squid
    This should work:
    $kw= $row['loc'];
    $kw= explode('.com/', $kw);
    $kw= str_replace('-', ' ', $kw[1]);

    // $kw should be the actual keyword like "dog training tips online"
    {{ DiscussionBoard.errors[5982908].message }}

Trending Topics