GetSimple Support Forum
I18N Special Pages - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: Plugins (http://get-simple.info/forums/forumdisplay.php?fid=13)
+--- Thread: I18N Special Pages (/showthread.php?tid=2747)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22


RE: I18N Special Pages - hameau - 2015-07-06

Do you have one special page per item, or are all items on one page? Are you also using the I18N Navigation and I18N Search plugins?

If you have each item on its own page, you can display the list by using the search (for example, search by tag for different sections of your price list). The search results can be ordered the same as the 'menu order' (even if the pages are not in a menu, they can still have a menu order). The menu order is set by drag-&-drop ('Edit Navigation Structure'), which also sets the list display order.


RE: I18N Special Pages - Carlos - 2015-07-07

Replying to this post (Russian months issues)

@Oleg06

Change this:
Code:
get_special_field_date(PARAMS);
to this:
Code:
echo str_replace(
   array("Январь","Февраль","Март", "Апрель","Май","Июнь","Июль","Август","Сентябрь", "Октябрь","Ноябрь","Декабрь"),
   array("Января","Февраля","Марта","Апреля","Мая","Июня","Июля","Августа","Сентября","Октября","Ноября","Декабря"),
   return_special_field_date(PARAMS)
);

Note: Replace the word PARAMS by your parameters (field name -"creDate" or "pubDate"-, optional date format)


RE: I18N Special Pages - Oleg06 - 2015-07-07

cheers, Carlos, finally solved the problem of Russian users with dates Smile


Gallery list with Special Pages - pikku - 2015-07-07

Hi, I posted allready a Reply in the Search Plugin´s Forum to explain my problem
http://get-simple.info/forums/showthread.php?tid=1256&pid=51894&highlight=list+of+galleries#pid51894

Unfortunately there was no answer!
Maybe the explanation of the problem was to weird  Confused , or it was the wrong forum - but I have to mix several plugins.

I´m trying to solve my problem with a simplier aproach now, but there is still some coding problem.
A problem for me as a non-coder, but for php guys it shouldn´t be a major task:

I have several galleries (I18N) and my users will add more.
I have a page where I want to list the galleries.
To make it easier for the users, I set up "I18N Special Pages" with the "...extras"-Plugin.
So in the page config there is no content field, but extra text-fields to type the names of the galleries (witch is also the name of the galleries page). There can be added more alike fields by the user.
The field-name is "gallerie".

In the view field of the special pages type I´m calling the field name like this to get the galleries titles:
Code:
<h2><?php get_special_field('gallerie'); ?></h2>
this works fine, so it seems to be set up correctly.

To get a link to a gallery with the first thumbnail I had to code:
Code:
<?php get_i18n_gallery_link('my-gallery-name',
         array('url'=>'my-gallery-slug', 'thumb'=>0)); ?>
If I replace the variable with a real gallery name by hand, this works as well and I have a thumb with the titles.

But how can I get the above call for the name into the call for a gallery-link!?
As I said, I´m no coder, so I messed around a lot with the code, but could not find the right way.

Please, if someone is so kind to write me a few lines of nice code with get.. within a get...!

Just to be shure, you get me, I right down what I mean, but of course, that´s not correct php anymore:

Code:
<?php get_i18n_gallery_link('get_special_field('gallerie');',
         array('url'=>'get_special_field('gallerie');', 'thumb'=>1)); ?>

hope you can help me,
thanks

pikku


RE: I18N Special Pages - mvlcek - 2015-07-08

(2015-07-07, 01:54:16)pikku Wrote: But how can I get the above call for the name into the call for a gallery-link!?
As I said, I´m no coder, so I messed around a lot with the code, but could not find the right way.

Please, if someone is so kind to write me a few lines of nice code with get.. within a get...!

Just to be shure, you get me, I right down what I mean, but of course, that´s not correct php anymore:


Code:
<?php get_i18n_gallery_link('get_special_field('gallerie');',
         array('url'=>'get_special_field('gallerie');', 'thumb'=>1)); ?>

The following should work:

Code:
<?php get_i18n_gallery_link(return_special_field('gallerie'),
         array('url'=>return_special_field('gallerie'), 'thumb'=>1)); ?>

get_special_field will output the content of the field, return_special_field will just return it and make it usable in the gallery call. Of course this assumes that gallery name and slug are identical.


RE: I18N Special Pages - MicroCAD - 2015-08-01

Hi,


I need help to solve a problem with the search rendering of special pages.


I'm using an external class with some arrays to manage static translations in the pages.

Everything works well in the pages, but now I would like to use the same translation file in the parent page, where I'm using the

get_i18n_search_results to display all the childrens.

I'm trying to include the file in the plugin's configuration, in the search tab, but it works only for the first children!

If I use require, it works only for the first children, and then breaks the page.

If I use require_once, it works only for the first children, don't breaks the page but leaves empty the other children.

Some ideas about how solve it?

I know that the search tab propose the translations, but these texts are use in 5 different special pages, each one has to be translated in 4 languages.
Change it locally would be a nightmare.

I'm using special page with extra addons.

Thank you soooooo much for any help!


RE: I18N Special Pages - Carrara - 2015-08-09

As substiuir the characters || on the other, for example a comma?


RE: I18N Special Pages - morvy - 2015-09-30

@mvlcek can you replace & with &amp; for getImage function ? I know it's just small thing, but you know, validators... Smile


RE: I18N Special Pages - mvlcek - 2015-10-01

(2015-09-30, 20:48:21)morvy Wrote: @mvlcek can you replace & with &amp; for getImage function ? I know it's just small thing, but you know, validators... Smile

I18nSpecialPages::getImage (and return_special_field_image) returns the URL to an image - and the URL has & and not &amp;
return_xxx functions return the value as is - you have to do the encoding, if needed.
Thus you can use the result to do something in PHP like output the plain URL to a log; if you use the result of this method to output the URL on your page, you must wrap it with htmlspecialchars(...).
Or use get_special_field_image, which output the complete link.


RE: I18N Special Pages - morvy - 2015-10-01

Maybe I wrongly expressed my idea .. I just checked the site with w3 validator and got error because image thumbnail had "&" instead of "&amp;" in the url, so yes, I fixed it, but I can't find any other use where simple & is expected so I thought that setting it to "&amp;" as default would be fine


RE: I18N Special Pages - flanders - 2015-10-08

Hi

I'm using this plugin but it doesn't work!

I use the 3.3.7 version in local pc and I don't see errors in the log file.


[Image: Schermata_2015_10_07_alle_18_41_14.jpg]


edit : SOLVED !

I had changed in gsconfig.php
define('GSEDITORTOOL', 'full'); 

then I comment it
#define('GSEDITORTOOL', 'full');

now I'm working.


RE: I18N Special Pages - Carlos - 2015-10-09

Try with:

Code:
define('GSEDITORTOOL', 'Full');

Note the uppercase F in 'Full'.


RE: I18N Special Pages - 0zz - 2015-10-13

Is there a solution to randomly select certain number of search results? So, let's say I have 20 items with tag "smartphone" created via Special Pages and I want to show only 5 random on a page, so that I will get different items displayed every time page reloads... What would be the best way to make it?

Thank you!


RE: I18N Special Pages - morvy - 2015-10-13

search result returns array, so you can shuffle its content and shrink array to 5 elements, var_dump/print_r functions can be very handy here Wink


RE: I18N Special Pages - 0zz - 2015-10-14

Thank you, morvy, but PHP is not my best talent (( Not at all, in fact.
could you, please, extend your suggestion to working function? ))

Thank you!


RE: I18N Special Pages - Tyblitz - 2015-10-16

(2015-10-14, 02:57:08)0zz Wrote: Thank you, morvy, but PHP is not my best talent (( Not at all, in fact.
could you, please, extend your suggestion to working function? ))

Thank you!

Hi 0zz,

It is somewhat weird to display totally random results, you would more often display, eg. the latest five. Anyway here's how you would do it with PHP (comments for explanation).

PHP Code:
<?php 
// replace this with the tag you want to search for
$tag 'smartphone';
// Return search results for the tag, starting at 0, including all entries
// For more info see http://mvlcek.bplaced.net/get-simple/i18nsearch
$searchresults return_i18n_search_results($tagnull00);


// we create a function which will return $amount of random numbers, between $min and $max
function generateRandomNumbers($amount$min 0$max 100) {
  // create an array to store the random indexes so we have no duplicates
  $indexes = array();
  // avoid endless while loop if the amount given is bigger than the possible amount of values
  $max_len $max-$min+1;
  for ($i 0$i $amount$i++) {
    
// calc. a random value between $min and $max
    $index mt_rand($min$max);
    if (
count($indexes) < $max_len) {
    
  // make sure we don't push duplicate values 
       while (array_search($index$indexes) !== FALSE) {
          $index mt_rand($min$max);
       }
       array_push($indexes$index);
    }
  }
  return $indexes;
}

// get 5 random numbers from all entries
$items_to_show generateRandomNumbers(50$searchresults['totalCount']);

foreach (
$items_to_show as $index) {
  
// here you may use any display logic to output what you like (eg. getExcerpt; pubDate; ...)
 
 echo $searchresults['results'][$index]->content;
}

?>

As for var_dump and print_r; these are debug functions which will print the output of a PHP variable on the page (so you can preview your results before doing something with them).
For example, in the codeblock above, you could have done:
PHP Code:
<?php var_dump($searchresults['results']); ?>

And it would show you the results returned by i18n_search in PHP-format (arrays and objects).


RE: I18N Special Pages - 0zz - 2015-10-16

Hi, Tyblitz!
This looks like "WOW!" Thank you for your time and really throrought work and explanations!
Random display is a need, when, for example, you want to display similar goods/items under a selected item. Or, when you have many articles, let's say about celebrities or animals, and you want to display them randomly, so that every time visitor reloads page, he gets new anonses displayed.

Could you please, give more information about how to use other options for displaying articles? Like use numWords, lang and showPaging options? Sorry, this must be easy, but I am not familiar with naitive PHP even ((


RE: I18N Special Pages - Tyblitz - 2015-10-17

The $lang parameter filters out articles in another language. If you had 5 articles with the tag 'smartphone', from which 2 in French, and 3 in English, and you set $lang to 'en', you would get 3 results.
The $numWords parameter defines how long excerpts are in amount of words. You can achieve the same in my example if you did (in the foreach loop):

PHP Code:
<?php echo $searchresults['results'][$index]->getExcerpt($searchresults['results'][$index]->content50); ?>
Which will display the first 50 words of an article's content.
$showPaging is a parameter for the get_ function, so you can't use it in the example I provided. Read more about those parameters in the docs.


RE: I18N Special Pages - 0zz - 2015-10-17

Thank you, Tyblitz so much!
I know, of course, about parameters and what they are for, but I had difficulties with applying them in your suggested php code above.

Now it is more or less clear, however I am still trying to figure out how to display articles in the way I need. Output display settings in SpecialPages plugin do not work, obviously..

Also, I may need to add some html tags to wrap the search-results, since with your code only pure text is displayed or paragraphs if i set '1p' as an excerpt..


RE: I18N Special Pages - Tyblitz - 2015-10-17

Hey 0zz,

The requirement to display completely random posts cannot be fulfilled with the get_ function; that's why you need to do some additional processing, and cannot use all its handy parameters. The code I provided is intended to work as a replacement for the 'search' type of display (but in a theme template, not in the special page fields, in a case like the example you provided about random linked articles).

You can completely customize the foreach function, eg: 

PHP Code:
<?php 
foreach ($items_to_show as $index) {
 
 $article $searchresults['results'][$index];
 
 echo '<div class="article">';
 
 echo '<h4>' $article->title '</h4>';
 
 echo 'Published on: <time datetime="' $article->pubDate '">' $article->pubDate '</time>';
 
 echo '<p>' $article->getExcerpt($article->content50) . '</p>';
 
 echo '</div>';
}
?>
Quote:Output display settings in SpecialPages plugin do not work, obviously..

What do you mean? Of course they work, eg in a special page View tab:
PHP Code:
<?php 
  
echo '<h1>'get_special_field('title'); echo '</h1>';
  echo 
'<div class="content">'get_page_content(); echo '</div>';
?>



RE: I18N Special Pages - 0zz - 2015-10-18

Now it makes so much more sense, Tyblitz! I just wasn't able to figure out how to apply additional html+styling for the results.. Thank you, kind man!


RE: I18N Special Pages - Oleg06 - 2015-10-23

is it possible in the file conf_edit.php in line 40 add _ for name using checkbox as a tag.


RE: I18N Special Pages - datiswous - 2015-12-14

Idea: 
  • Option to dissable a Special Page Type. 
So the ones you don't use for the moment you can hide on section Create New Special Page


RE: I18N Special Pages - simba - 2015-12-29

I wanted to auto get thumbs to my custom field "image". So with a little help from a friend I've devised something that works quite well. Im dropping it here, it may come useful. Also - is there a simpler way to do this?

PHP Code:
<?php 

    $image 
$item->image;
    $pieces explode("/",$image);
    $needle "uploads";
    $replacement "thumbs";
    for($i=0;$i<count($pieces);$i++) {
       if($pieces[$i] == $needle) {
       $pieces[$i] = $replacement;
       }
    }
    $f array_slice($pieces, -1);
    $path array_slice($pieces0, -1);
    echo implode($path"/") . "/thumbnail." implode($f"/");
?>



RE: I18N Special Pages - mvlcek - 2015-12-30

(2015-12-29, 21:36:43)simba Wrote: I wanted to auto get thumbs to my custom field "image". So with a little help from a friend I've devised something that works quite well. Im dropping it here, it may come useful. Also - is there a simpler way to do this?


PHP Code:
<?php 

    $image 
$item->image;
    $pieces explode("/",$image);
    $needle "uploads";
    $replacement "thumbs";
    for($i=0;$i<count($pieces);$i++) {
       if($pieces[$i] == $needle) {
       $pieces[$i] = $replacement;
       }
    }
    $f array_slice($pieces, -1);
    $path array_slice($pieces0, -1);
    echo implode($path"/") . "/thumbnail." implode($f"/");
?>

You can use return_special_field_image('image', 120, 90, false) to get the link or get_special_field_image('image', 'My image description', 120, 90, false) to output the whole img tag for a scaled version (thumbnail) in size 120x80 of the image in field 'image'. The scaled version is created when first accessed.