Posts: 2,094
Threads: 54
Joined: Jan 2011
(2015-01-21, 08:50:32)Tyblitz Wrote: I'm a great supporter of i18n but for a PHP noob like me the documentation on mvlcek.bplaced.net didn't really suffice, especially not about the output of the return_i18n_menu_data function.
Yes, the description is for programmers and rather short ;-)
You can always use the PHP function print_r to output a variable, e.g. the returned structure of return_i18n_menu_data.
(2015-01-21, 08:50:32)Tyblitz Wrote: So after a day of PHP research and fiddling with i18n plugins in GetSimple, I wrote a more comprehensive piece of documentation here: http://codepen.io/Webketje/full/VYbxmy/. Feel free to check it out (especially Martin, as you may point me to errors, if any).
Nice work. However, the $slug need not be the current page: there are use cases where this is not the case, e.g. http://mvlcek.bplaced.net/get-simple/mul...v-multiple.
You could also use custom rendering and not output the link for items with child pages, e.g.
Code: <li class="<?php echo $item->classes; ?>">
<?php if ($item->hasChildren) { ?>
<a href="<?php echo htmlspecialchars($item->link); ?>">
<?php echo htmlspecialchars($item->text); ?>
</a>
<?php } else { ?>
<?php echo htmlspecialchars($item->text); ?>
<?php } ?>
<?php if ($item->isOpen) { ?>
<ul><?php $item->outputChildren(); ?></ul>
<?php } ?>
</li>
Posts: 88
Threads: 19
Joined: May 2012
2015-02-05, 16:11:17
(This post was last modified: 2015-02-12, 17:46:17 by sarnaiz.)
NEED TO ADD MENU ORDER
Hi Martin,
I need to add order:menuOrder to the component code or my search results display code but don't know the proper syntax to make it work. Also, not sure which place is the right place to add it - in the component or in the search results code:
My component code:
PHP Code: <?php get_i18n_search_results(array('tags'=>'_special-grocery','HEADER'=>null)); ?>
My search results code:
PHP Code: <h3 class="search-entry-title"> <a href="<?php get_special_field('link','',false); ?>"> <?php get_special_field('title','',false); ?> </a> </h3>
<div class="search-entry-summary"><?php get_special_field('summary','',false); ?></div>
I've looked through things, but don't see an example of what to use and I'm not a programmer. :-)
The page is starting to shape up nicely thanks to help I've gotten here!
http://medbake.com/groceries/
Thank you for your help.
Posts: 88
Threads: 19
Joined: May 2012
(2015-02-05, 16:11:17)sarnaiz Wrote: NEED TO ADD MENU ORDER
Hi Martin,
I need to add order:menuOrder to the component code or my search results display code but don't know the proper syntax to make it work. Also, not sure which place is the right place to add it - in the component or in the search results code:
My component code:
PHP Code: <?php get_i18n_search_results(array('tags'=>'_special-grocery','HEADER'=>null)); ?>
My search results code:
PHP Code: <h3 class="search-entry-title"> <a href="<?php get_special_field('link','',false); ?>"> <?php get_special_field('title','',false); ?> </a> </h3>
<div class="search-entry-summary"><?php get_special_field('summary','',false); ?></div>
I've looked through things, but don't see an example of what to use and I'm not a programmer. :-)
The page is starting to shape up nicely thanks to help I've gotten here!
http://medbake.com/groceries/
Thank you for your help.
Please let me know if I have posted this in the wrong place. I thought it was pertaining to special pages rather than search since I am working in the search results for special pages.
Posts: 88
Threads: 19
Joined: May 2012
(2015-02-12, 17:48:32)sarnaiz Wrote: [quote='sarnaiz' pid='49614' dateline='1423116677']
NEED TO ADD MENU ORDER SOLVED
Hi Martin,
I need to add order:menuOrder to the component code or my search results display code but don't know the proper syntax to make it work. Also, not sure which place is the right place to add it - in the component or in the search results code:
My component code:
PHP Code: <?php get_i18n_search_results(array('tags'=>'_special-grocery','HEADER'=>null)); ?>
My search results code:
PHP Code: <h3 class="search-entry-title"> <a href="<?php get_special_field('link','',false); ?>"> <?php get_special_field('title','',false); ?> </a> </h3>
<div class="search-entry-summary"><?php get_special_field('summary','',false); ?></div>
I've looked through things, but don't see an example of what to use and I'm not a programmer. :-)
The page is starting to shape up nicely thanks to help I've gotten here!
http://medbake.com/groceries/
Thank you for your help.
SOLVED
PHP Code: <?php get_i18n_search_results(array('tags'=>'_special-grocery','order'=>'menuorder','HEADER'=>null)); ?>
I was able to figure out the syntax to add it to the component code and also I went back and reviewed the code on a site Martin had helped me with. I realized I had not added all special pages to the menu. I did that and then reviewed my code again and tried code above and it worked.
Posts: 87
Threads: 1
Joined: Nov 2012
Hi Martin, I need to check to see if a special field is empty - if it's empty, I want to hide it. I know how to do this in my template using the code below but can you show me how to accomplish this using a component?
PHP Code: <?php if (return_special_field('specialimg') != "") { ?><div class="entry-thumb"> <a href="<?php get_special_field('link','',false); ?>"><?php get_special_field_image('specialimg', return_special_field('title','',false), '492', '492'); ?></a> </div><?php } ?>
Thanks again!
Posts: 3,491
Threads: 106
Joined: Mar 2010
Code: <?php if (return_special_field('specialimg', "") != "") ...
Posts: 87
Threads: 1
Joined: Nov 2012
(2015-02-16, 17:15:13)Carlos Wrote: Code: <?php if (return_special_field('specialimg', "") != "") ...
Thanks for the quick reply Carlos, but I'm looking for the code to do this in a component, not in my template. Do you know how to do that?
Posts: 3,491
Threads: 106
Joined: Mar 2010
Oh sorry, I read too quickly (well I almost didn't read) and thought it was another issue.
Doesn't it work if you simply put your code in a component?
Posts: 87
Threads: 1
Joined: Nov 2012
(2015-02-17, 01:38:46)Carlos Wrote: Oh sorry, I read too quickly (well I almost didn't read) and thought it was another issue.
Doesn't it work if you simply put your code in a component?
No problem, Carlos. From my experience the template code looks like this:
PHP Code: <?php get_special_field('link','',false); ?>
And component code looks like this:
PHP Code: <?php echo $item->link; ?>
I've tried using the template code below in a component and it doesn't work so I just need to know how to convert this to work inside a component - thanks!
PHP Code: <?php if (return_special_field('specialimg') != "") { ?><div class="entry-thumb"> <a href="<?php get_special_field('link','',false); ?>"><?php get_special_field_image('specialimg', return_special_field('title','',false), '492', '492'); ?></a> </div><?php } ?>
Posts: 3,491
Threads: 106
Joined: Mar 2010
So I suppose you're using I18N Search to call the component.
It may be something like this (not tested)
Code: <?php if (!empty($item->specialimg)) { ?><div class="entry-thumb">
<a href="<?php echo htmlspecialchars($item->link); ?>"><?php echo $item->outputImage('specialimg', $item->title, 492, 492); ?></a>
</div><?php } ?>
Posts: 87
Threads: 1
Joined: Nov 2012
2015-02-17, 03:34:56
(This post was last modified: 2015-02-17, 03:35:19 by bensayers.)
(2015-02-17, 03:07:08)Carlos Wrote: So I suppose you're using I18N Search to call the component.
It may be something like this (not tested)
Code: <?php if (!empty($item->specialimg)) { ?><div class="entry-thumb">
<a href="<?php echo htmlspecialchars($item->link); ?>"><?php echo $item->outputImage('specialimg', $item->title, 492, 492); ?></a>
</div><?php } ?>
Yes, I'm using the i18n Search plugin to call the component:
PHP Code: <?php get_i18n_search_results(array('tags'=>'_special_junews','max'=>3,'component'=>'jusidebarnews','order'=>'menuOrder','numWords'=>30,'showPaging' => 1,'HEADER'=>null,'i18n'=>0)); ?>
The code you provided produces the following error:
Fatal error: Call to undefined function __get() in /home/clientfolder/public_html/plugins/i18n_search/searcher.class.php on line 115
Posts: 3,491
Threads: 106
Joined: Mar 2010
Oops.
Well I don't know if there's some way to generate the thumbnail other than hardcoding it with .../pic.php?p=...
Posts: 87
Threads: 1
Joined: Nov 2012
(2015-02-17, 03:56:16)Carlos Wrote: Oops.
Well I don't know if there's some way to generate the thumbnail other than hardcoding it with .../pic.php?p=...
Thanks anyway for trying Carlos, hopefully Martin will be able to shed some light.
Posts: 1,927
Threads: 88
Joined: Apr 2010
please tell me how to replace this code in the component
Code: <?php get_special_field_image('image', 'title', '300', '200'); ?>
in the component running this code, but you can not specify the image size
Code: <img src="<?php echo $item->image; ?>" />
Posts: 87
Threads: 1
Joined: Nov 2012
(2015-02-17, 08:24:30)Oleg06 Wrote: please tell me how to replace this code in the component
Code: <?php get_special_field_image('image', 'title', '300', '200'); ?>
in the component running this code, but you can not specify the image size
Code: <img src="<?php echo $item->image; ?>" />
I use TimThumb to crop images in components and it does a great job: https://code.google.com/p/timthumb/
PHP Code: <img src="/theme/themename/includes/php/timthumb.php?src=<?php echo $item->image; ?>&h=300&w=200&q=80" alt="<?php echo $item->title; ?>" />
Posts: 1,927
Threads: 88
Joined: Apr 2010
Posts: 16
Threads: 1
Joined: Jul 2012
Is it possible to make datepicker field? I need to specify the time, date, and year of the concert. I made three field drop-down list, is not comfortable.
Posts: 3,491
Threads: 106
Joined: Mar 2010
(2015-02-17, 03:56:16)Carlos Wrote: Well I don't know if there's some way to generate the thumbnail other than hardcoding it with .../pic.php?p=...
This is what I meant:
PHP Code: <img src="<?php get_site_url(); ?>plugins/i18n_specialpages/browser/pic.php?p=<?php echo substr($item->image, strpos($item->image, 'data/uploads/')+13); ?>&h=300&w=200&c=1" alt="<?php echo $item->title; ?>" />
That is, using Special Pages' own image resizing script.
Posts: 28
Threads: 2
Joined: Feb 2015
2015-03-07, 22:17:11
(This post was last modified: 2015-03-07, 22:23:37 by revotron.)
I don't seem to quite understand the logic of this plugin...
If I configure a special page and set up my fields, then the number of input fields for this special page seems to be "hardcoded" to the number of input fields created in the backend and rendered with the code snippets in the template file.
For example I want to display two input fields, one image field and one textfield for the image description. After I've created this fields in the admin panel I'll insert something like this in my template file: PHP Code: get_special_field_image('image')
and PHP Code: get_special_field('description')
So the user is only able to insert one image and one description. But how do I solve the problem if this input should be dynamically editable/expandable by a user in the backend?
For example:
If I want to have four images and four descriptions, I have to create four fields for images and textinputs. But after several weeks my client wants to add another image, so it's five images and descriptions in total instead of the preset four fields. How do I handle this situation? Is this possible with some loop? Or is the number really "hardcoded" and I have to add another field and another snippet in the template each time?
I hope you understand my question.. my English got a bit rusty.
Posts: 185
Threads: 8
Joined: Apr 2012
no, you create a template for this special page and you create search results page (for example) and in search you show all special pages of given type, taking only image and description ..
user in backend creates separate page for each image/description
Posts: 28
Threads: 2
Joined: Feb 2015
2015-03-08, 01:12:56
(This post was last modified: 2015-03-08, 01:41:22 by revotron.)
To be more precise I want to build a slider with this plugin. The user in the backend can add as many images and descriptions as he likes.
Is this even possible if I have to add separate pages for each image?
Can you give me some more details about the templates you were talking about, please?
Do I have to create a template in the plugin folder (i18n_specialpages > templates)?
Where and how do I create a search result page?
It seems a bit to inconvenient to me. Maybe there is a better plugin for this situation (repeatable custom fields for images/description in backend, which I can call in my template to build a slider)?
I'm new to getsimple CMS...
EDIT// Ok.. seems like I got this to work. But it doesn't feel right to create (sub)pages for every new content element and render them via "faked" search results. Moreover the source code of the rendered html is full of class="search-entry" and so on. I just want to have repeatable fields, that I can output in my template without any HTML structure so I can build it by myself for whatever I need those fields. Any suggestions?
Posts: 185
Threads: 8
Joined: Apr 2012
Posts: 28
Threads: 2
Joined: Feb 2015
(2015-03-08, 01:52:57)morvy Wrote: use i18n gallery plugin instead > http://get-simple.info/extend/plugin/i18n-gallery/160/
This plugin looks promising. I can't use any of the presets, but it looks like I could edit the plugin and create my own template file for it. Hmm…
But back to the Special Pages plugin. Is it possible to create repeatable fields or content areas without creating a "faked" search results page? This seems just like a sort of workaround?
Posts: 185
Threads: 8
Joined: Apr 2012
2015-03-09, 04:08:43
(This post was last modified: 2015-03-09, 04:11:59 by morvy.)
I've created a component like this (didn't test it)
PHP Code: <?php $results = return_i18n_search_results("_special_slides", null, 0, 10, '+menuOrder'); echo "<div id=\"slideshow\">"; foreach ($results['results'] as $n => $entry) { echo "<div class=\"slide-".$n."\">"; get_special_field_image($entry->image, $entry->title, "900px", "300px", true); echo "<span class=\"slide-description\">".$entry->content."</span>"; echo "</div>"; } echo "</div>"; ?>
then in a template you call that component ..
special page needs only image to be added, as title and content are default and can be used also ..
Posts: 2,094
Threads: 54
Joined: Jan 2011
I18n Special Pages version 1.3.4:- optionally index the name of a checkbox as tag (@Oleg06, @Alexander_)
|