my code stock.com

TOMADO DE FARMA24 V2.0

[actualnews_init an_nick="xxxxx" an_idioma="xxxx" an_lang="xxxx"]
[grid_plus name="Noticias" an_nick="indacep" an_categoria="0" an_idioma="xxxx" an_lang="xxxx" an_limite="0" an_paglimite="9"]

Snippet options

Download: Download snippet as header-larga.html.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

<?php 
/// FUNCION PARA IMPRIMIR META. FALTA REMPLAZAR EN CASO DE QUE EXISTA.
/* function stan_hook_example() {
echo '<meta name="description" content="Meta Description for this Page." />';
} add_action( 'wp_head', 'stan_hook_example' );*/

function toAscii($text){
  $text = preg_replace('~[^\pL\d]+~u', '-', $text);
  $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
  $text = preg_replace('~[^-\w]+~', '', $text);
  $text = trim($text, '-');
  $text = preg_replace('~-+~', '-', $text);
  $text = strtolower($text);
  if (empty($text)) {
    return 'n-a';
  }
  return $text;
}

global $post;
global $an_nick;
global $an_lang;
global $an_categoria;
$content = $post->post_content;
if ( !empty( $content ) ) :
    echo do_shortcode($content);
endif;
$sitename = get_bloginfo( 'name' );
$cliente =get_bloginfo( 'name' );
$urlhttp = get_option( 'siteurl' );
$currentUrl = $_SERVER["REQUEST_URI"];
$arrUrlParts = explode( "/" , $currentUrl );
$idioma=$an_lang;

//echo "<pre>"; print_r($arrUrlParts); echo "</pre>";
$url='https://www.actualnews.es/zona_clients/rss_complet.php?nick='.$an_nick.'&lang='.$an_lang.'&contingut=llarg&idNoticia='.$arrUrlParts['2'];
//$url='https://www.actualnews.es/zona_clients/rss_complet.php?nick=XXXXXXXXXXXXX.com&lang='.$lenguaje.'&contingut=llarg&idCategoria=XXXXXXXXXXXX&l=XXXXXXXXXX';
//echo "<pre>"; print_r($url); echo "</pre>";

$xml = simplexml_load_file($url);
$xml2 = json_decode( json_encode($xml->noticies) , true); 
//echo "<pre>"; print_r($xml2);echo "</pre>";
//echo "<pre>"; echo count($xml2['noticia']); echo "</pre>";


if($idioma=='cat') {
    $idiomahtml ="ca";
    $langcode = "ca_ES";
    if(count($xml2['noticia'])<1) {
        header('Location: /noticies');
    } 
    $volver="Totes les notícies";
    $urln="noticies"; 
    
}

elseif($idioma=='eng') {
    $idiomahtml ="en";
    $langcode = "en_GB";
    if(count($xml2['noticia'])<1) {
        header('Location: /all-news');
    } 
    $volver="Back to all news";
    $urln="all-news";
}

elseif($idioma=='fra') {
    $idiomahtml ="fr";
    $langcode = "fr_FR";
    if(count($xml2['noticia'])<1) {
        header('Location: /actualites');
    } 
    $volver="";
    $urln="";      
}
else{
    $idiomahtml ="es";
    $langcode = "es_ES";
    if(count($xml2['noticia'])<1) {
        header('Location: /noticias');
    } 
    $volver="Volver a notícias";
    $urln="noticias";     
}

$id =$arrUrlParts['2'];
$fecha =strftime("%d-%b-%Y", strtotime($xml2['noticia']['data']));
$fechahtml =strftime("%d-%b-%Y", strtotime($xml2['noticia']['data']));
$foto = $xml2['noticia']['imatge_principal'];
$imagehtml = $xml2['noticia']['imatge_principal'];
$htmltitle = $xml2['noticia']['title'];
$titulo = $xml2['noticia']['title'];
$categoria ="ncategoria"; //FALTA ESTO
$url=$currentUrl;
$descripcion =$xml2['noticia']['description'];	
$i=0;
$imatgesdecode = '';

// IMAGEN PRINCIPAL SOLAMENTE
if(isset($xml2['noticia']['imatge_principal']) AND !isset($xml2['noticia']['imatges'])){
    //echo "<pre> IMAGEN PRINCIPAL SOLAMENTE:  "; print_r($urlsimatges);echo "</pre>";
    $imatgesdecode=$xml2['noticia']['imatge_principal'];
} 

// CON IMAGEN PRINCIPAL CON VARIAS IMAGEN
elseif(isset($xml2['noticia']['imatge_principal']) AND isset($xml2['noticia']['imatges']) AND count($xml2['noticia']['imatges'])==1) {
    //echo "<pre> CON IMAGEN PRINCIPAL CON VARIAS IMAGEN:  "; print_r($xml2['noticia']['imatges']['imatge']); echo "</pre>";
    $imatgesdecode=$xml2['noticia']['imatge_principal'];
    foreach ($xml2['noticia']['imatges']['imatge'] as $img) {
        $imatgesdecode.=$urlsimatges .= $img['ruta'].",";
    }
    $imatgesdecode = substr(trim($urlsimatges), 0, -1);
} 

// CON IMAGEN PRINCIPAL CON UNA IMAGEN
elseif(isset($xml2['noticia']['imatge_principal']) AND isset($xml2['noticia']['imatges']) AND count($xml2['noticia']['imatges'])==1 AND count($xml2['noticia']['imatges']['imatge'])==3) { 
    //echo "<pre> CON IMAGEN PRINCIPAL CON UNA IMAGEN:  "; print_r($urlsimatges);echo "</pre>";
    $imatgesdecode=$xml2['noticia']['imatge_principal'];
    if(isset($xml2['noticia']['imatges']['imatge']['ruta'])) {
        $imatgesdecode.=$xml2['noticia']['imatges']['imatge']['ruta'];                
    }    
} 

else {
    //echo "<pre> ¿donde esta la imagen?, ¿sin imagen la noticia?:  "; print_r($urlsimatges);echo "</pre>";
    $imatgesdecode='https://dummyimage.com/600x400/420042/ffffff.png&text=Sin+Imagen';
}

//print_r($imatgesdecode);
//$imatgesdecode ="https://dummyimage.com/600x400/000/fff";
$urlsimatges = base64_encode(urlencode($imatgesdecode));
$scdata .= '[vc_gallery interval="3" external_img_size="400x200" source="external_link" custom_srcs="#E-8_'.$urlsimatges.'"]';
?>





<?php
/**
 * Template name: AN Noticia (Apicona)
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages and that other
 * 'pages' on your WordPress site will use a different template.
 *
 * @package WordPress
 * @subpackage Apicona
 * @since Apicona 1.0
 */

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.