Kjapp og trygg hosting for Wordpress

Spørring inni variabel

JoachimO

Medlem
Hepp

jeg sliter litt med å få følgende til å fungere:

I et php-script har jeg følgende.

PHP:
$url = "http://XXXXXXX/XXXX/?q=<SPØRRING>&api_key=XXXXXX";

<SPØRRING> skal da være avhengig av sidens tittel, som i Joomla hentes med følgende kode:

PHP:
<?php
	$option = JRequest::getCmd('option');
	$view = JRequest::getCmd('view');
	if ($option=="com_content" && $view=="article") {
    	$ids = explode(':',JRequest::getString('id'));
    	$article_id = $ids[0];
    	$article =& JTable::getInstance("content");
    	$article->load($article_id);
    	echo $article->get('title');
}?>

Jeg har forsøkt

PHP:
$url = "http://XXXXX/XXX/?q=
		$option = JRequest::getCmd('option');
		$view = JRequest::getCmd('view');
		if ($option=='com_content' && $view=='article') {
    		$ids = explode(':',JRequest::getString('id'));
    		$article_id = $ids[0];
    		$article =& JTable::getInstance('content');
    		$article->load($article_id);
    		echo rawurlencode($article->get('title'));
		}&api_key=XXXXX";

Men dette ser ikke ut til å fungere helt, da ingen resultater returneres.

Noen forslag?
 

Thomas Pedersen

Pornogründer
PHP:
    $option = JRequest::getCmd('option');
    $view = JRequest::getCmd('view');
    if ($option=="com_content" && $view=="article") {
        $ids = explode(':',JRequest::getString('id'));
        $article_id = $ids[0];
        $article =& JTable::getInstance("content");
        $article->load($article_id);
         
        $url = "http://XXXXXXX/XXXX/?q=".urlencode($article->get('title'))."&api_key=XXXXXX"; 
    }
 

JoachimO

Medlem
Takker for tipset. Fant en annen løsning som også fungerte

PHP:
$tittel = rawurlencode($article->get('title'));
$url = "http://search.tek.no/prisguide/?q=$tittel&api_key=xxxxxxxx";
 
Topp