Posts: 423
Threads: 15
Joined: Mar 2011
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.
--
Nick.
Posts: 3,491
Threads: 106
Joined: Mar 2010
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)
Posts: 1,928
Threads: 88
Joined: Apr 2010
cheers, Carlos, finally solved the problem of Russian users with dates
Posts: 11
Threads: 0
Joined: Jun 2015
Hi, I posted allready a Reply in the Search Plugin´s Forum to explain my problem
http://get-simple.info/forums/showthread...s#pid51894
Unfortunately there was no answer!
Maybe the explanation of the problem was to weird , 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
Posts: 2,094
Threads: 54
Joined: Jan 2011
(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.
Posts: 12
Threads: 0
Joined: Apr 2014
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!
Posts: 41
Threads: 10
Joined: Aug 2014
2015-08-09, 03:26:33
(This post was last modified: 2015-08-09, 03:26:47 by Carrara.)
As substiuir the characters || on the other, for example a comma?
Posts: 185
Threads: 8
Joined: Apr 2012
@mvlcek can you replace & with & for getImage function ? I know it's just small thing, but you know, validators...
Posts: 2,094
Threads: 54
Joined: Jan 2011
(2015-09-30, 20:48:21)morvy Wrote: @mvlcek can you replace & with & for getImage function ? I know it's just small thing, but you know, validators...
I18nSpecialPages::getImage (and return_special_field_image) returns the URL to an image - and the URL has & and not &
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.
Posts: 185
Threads: 8
Joined: Apr 2012
Maybe I wrongly expressed my idea .. I just checked the site with w3 validator and got error because image thumbnail had "&" instead of "&" 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 "&" as default would be fine
Posts: 11
Threads: 1
Joined: Sep 2015
2015-10-08, 05:00:30
(This post was last modified: 2015-10-08, 05:54:38 by flanders.)
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.
edit : SOLVED !
I had changed in gsconfig.php
define('GSEDITORTOOL', 'full');
then I comment it
#define('GSEDITORTOOL', 'full');
now I'm working.
Posts: 3,491
Threads: 106
Joined: Mar 2010
Try with:
Code: define('GSEDITORTOOL', 'Full');
Note the uppercase F in 'Full'.
Posts: 102
Threads: 7
Joined: Dec 2011
2015-10-13, 14:43:25
(This post was last modified: 2015-10-13, 14:50:56 by 0zz.)
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!
Posts: 185
Threads: 8
Joined: Apr 2012
2015-10-13, 17:46:57
(This post was last modified: 2015-10-13, 17:47:12 by morvy.)
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
Posts: 102
Threads: 7
Joined: Dec 2011
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!
Posts: 305
Threads: 15
Joined: Mar 2014
2015-10-16, 06:47:40
(This post was last modified: 2015-10-16, 06:49:11 by Tyblitz.)
(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($tag, null, 0, 0);
// 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(5, 0, $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).
Posts: 102
Threads: 7
Joined: Dec 2011
2015-10-16, 16:03:19
(This post was last modified: 2015-10-16, 16:17:32 by 0zz.)
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 ((
Posts: 305
Threads: 15
Joined: Mar 2014
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]->content, 50); ?>
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.
Posts: 102
Threads: 7
Joined: Dec 2011
2015-10-17, 15:55:52
(This post was last modified: 2015-10-17, 16:14:48 by 0zz.)
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..
Posts: 305
Threads: 15
Joined: Mar 2014
2015-10-17, 22:57:57
(This post was last modified: 2015-10-17, 23:08:37 by Tyblitz.)
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->content, 50) . '</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>'; ?>
Posts: 102
Threads: 7
Joined: Dec 2011
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!
Posts: 1,928
Threads: 88
Joined: Apr 2010
is it possible in the file conf_edit.php in line 40 add _ for name using checkbox as a tag.
Posts: 1,247
Threads: 82
Joined: Feb 2011
2015-12-14, 21:03:22
(This post was last modified: 2015-12-14, 22:55:55 by datiswous.)
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
Posts: 3
Threads: 0
Joined: Mar 2014
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($pieces, 0, -1); echo implode($path, "/") . "/thumbnail." . implode($f, "/"); ?>
Posts: 2,094
Threads: 54
Joined: Jan 2011
(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($pieces, 0, -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.
|