Jump to content

jumasol

Members
  • Posts

    11
  • Joined

  • Last visited

Everything posted by jumasol

  1. I have tested it again looking for some error and not found anything.
  2. I have seen no parse errors. Can you tell me if you see some error in the script: <?php $DomDocument = new DOMDocument(); $DomDocument->preserveWhiteSpace = false; $DomDocument->load('http://www. the website .com/index.php?option=com_xmap&view=xml&tmpl=component&id=1'); $DomNodeList = $DomDocument->getElementsByTagName('loc'); foreach($DomNodeList as $url) { $file = '/css' . strrchr($url->nodeValue,'/') . '.css'; $urls[] = $url->nodeValue; if(file_exists($file)) if(in_array("http://www. the website .com/link-a",$urls)){ echo '<link href="' . $file . ' rel="stylesheet" type="text/css" />'; } } ?>
  3. Thanks for replying. I would like to abuse of your help, but I must doing something wrong because now it doesn't work. My try: <?php $DomDocument = new DOMDocument(); $DomDocument->preserveWhiteSpace = false; $DomDocument->load('http://www. the website .com/index.php?option=com_xmap&view=xml&tmpl=component&id=1'); $DomNodeList = $DomDocument->getElementsByTagName('loc'); foreach($DomNodeList as $url) { $file = '/css' . strrchr($url->nodeValue,'/') . '.css'; $urls[] = $url->nodeValue; if(file_exists($file)) if(in_array("http://www. the website .com/link-a",$urls)){ echo '<link href="' . $file . ' rel="stylesheet" type="text/css" />'; } } ?>
  4. Hi. After some time looking for the way to check the presence of links in a sitemap to add specific css styling in the head of my site, I have this script that works perfectly: <?php $DomDocument = new DOMDocument(); $DomDocument->preserveWhiteSpace = false; $DomDocument->load('http://www. el sitio .com/index.php?option=com_xmap&view=xml&tmpl=component&id=1'); $DomNodeList = $DomDocument->getElementsByTagName('loc'); foreach($DomNodeList as $url) { $urls[] = $url->nodeValue; } if(in_array("http://www. the web site .com/link-a",$urls)){ $css= '<link href="/css/link-a.css" rel="stylesheet" type="text/css" />'; } echo $css; ?> It looks for tag names in the loc tags of a sitemap to provide an array, offering the possibility to add a css for a given link. The problem is that when I add more that two conditionals the script inserts just the first and the last one. In this case, with five elements, just link-a.css and link-e.css appear in the head tag. <?php $DomDocument = new DOMDocument(); $DomDocument->preserveWhiteSpace = false; $DomDocument->load('http://www. el sitio .com/index.php?option=com_xmap&view=xml&tmpl=component&id=1'); $DomNodeList = $DomDocument->getElementsByTagName('loc'); foreach($DomNodeList as $url) { $urls[] = $url->nodeValue; } if(in_array("http://www. the web site .com/link-a",$urls)){ $css= '<link href="/css/link-a.css" rel="stylesheet" type="text/css" />'; } if(in_array("http://www. the web site .com/link-b",$urls)){ $css= '<link href="/css/link-b.css" rel="stylesheet" type="text/css" />'; } if(in_array("http://www. the web site .com/link-c",$urls)){ $css= '<link href="/css/link-c.css" rel="stylesheet" type="text/css" />'; } if(in_array("http://www. the web site .com/link-d",$urls)){ $css= '<link href="/css/link-d.css" rel="stylesheet" type="text/css" />'; } if(in_array("http://www. the web site .com/link-e",$urls)){ $css= '<link href="/css/link-e.css" rel="stylesheet" type="text/css" />'; } echo $css; ?> Well, my level is basic, and I would appreciate some advice on the problem, and a suitable way to gather those elements in a single script, since there are some scores of them in my project. Thanks very much.
  5. Hi. I am intended upon getting some css style in the head of my site when certain links are published in a given URL in it (namely the sitemap xml of the site). So far, I have reached this point to create an array to list the URLs in the page: <?php $urls = array(); $DomDocument = new DOMDocument(); $DomDocument->preserveWhiteSpace = false; $DomDocument->load('http://www. sitio .com/index.php?option=com_xmap&view=xml&tmpl=component&id=1'); $DomNodeList = $DomDocument->getElementsByTagName('loc'); foreach($DomNodeList as $url) { $urls[] = $url->nodeValue; } //display it echo "<pre>"; print_r($urls); echo "</pre>"; ?> Which displays this array precisely: Array ( [0] => http://www. sitio .com/enlace-a [1] => http://www. sitio .com/enlace-b [2] => http://www. sitio .com/enlace-c [3] => http://www. sitio .com/enlace-d [4] => http://www. sitio .com/enlace-e [5] => http://www. sitio .com/enlace-f [6] => http://www. sitio .com/enlace-g [7] => http://www. sitio .com/enlace-h [8] => http://www. sitio .com/enlace-i ) The question now is how to get any of them (for instance "enlace-b") in some conditional script to insert the css file. I would really appreciate some help. Best regards.
  6. No. What I am trying to detect link names in a sitemap. The sitemap might be an xml or html file. When a certain link with a given name is in the page, a css file would be included in the index. Thus, and in this case, www. sitio com/descriptions in the sitemap.
  7. This other option does not work either. And the url links to an html document: <?php $ruta="http://www. sitio .com/sitemap"; $dom=new DOMDocument; $dom->preserveWhiteSpace= FALSE; $dom->load($ruta); $links=$dom->getElementsByTagName('descriptions'); foreach($links as $link){ echo '<link href="/css/xxxxxxxxxxxxxxxxxxx.css" rel="stylesheet" type="text/css" />'; } ?>
  8. I have found this: <?php $ruta="http://www. sitio .com/index.php?option=com_xmap&view=xml&tmpl=component&id=1"; $dom=new DOMDocument; $dom->preserveWhiteSpace= FALSE; $dom->load($ruta); $links=$dom->getElementsByTagName('descriptions'); foreach($links as $link){ echo '<link href="/css/xxxxxxxxxxxxxxxxxxx.css" rel="stylesheet" type="text/css" />'; } ?> But does not work for some reason. The sitemap link is correct and there is an hyperlink to "descriptions", but the script does not work. Some comment?
  9. No. Just detect a link with a certain word (for instance "section/usa" in a link) in the html code of a site, and then insert a css file or style in the index.php to be applied to the whole site. The link (example = <link href="templates/section/usa.html" >USA</a>) is in the html code and the part ""section/usa" is what must be detected through php. So the script would be in the index.php, searching for such words in all the links in a given page within the website.
  10. Hi. I am looking for some script to detect if there is a link with a certain word in an concrete page to insert css style in it. I have checked different proposals, but none of them offers a correct solution. Thanks for any reply.
  11. Hi everybody and congratulations for being part of this forum. Well the case is that being a beginner in this thing called php, I am looking for an elegant, functional way to detect active categories in a Joomla!-based site. The idea is to apply certain css rules to an entire site when certain categories are active. In fact, specific css styles for each active category. The administrator in charge of the site will not have any control over the css files and their implementation, so I have to leave the site prepared in terms of styling. The site will have a good number of categories to be activated and deactivated whenever the webmaster consider the opportunity. Do you know some approach to the problem? Some practical example or idea. Best regards.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.