Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
images in pages_excerpts
#1
I have images in the beginning of my pages which I want to show in their excerpts. I tried commenting out

$excerpt = htmlspecialchars_decode($excerpt);

in pages_exerpts.php

it worked on my localhost server but not online which showed the damaged image icon instead of the images.

How do I make the images appear in the excerpts?

[EDIT] Also, the text loses its formatting and line breaks. I want it to maintain its formatting.
Reply
#2
Doesn't using the built-in code do this:

Code:
<?php get_page_excerpt($length, 'false'); ?>

Or are you talking about having excerpts in search results as opposed to displaying the excerpt on the beginning of the page itself?
Reply
#3
I have many child pages whose excerpts I want to display on the parent page. Ideally I would have used the News Manager if it supported categories because I need to do it for many parent pages.

There are images on the top of the child pages which I want to display in the excerpt on the parent page.
Reply
#4
Install I18N Search, then on your parent page put the following content in:

Code:
(% searchresults tags="_parent_SLUG" numWords="Xp" %)

Replacing SLUG with the slug of the parent and X with the maximum number of paragraphs you want to display in your excerpt. This method maintains whatever formatting exists (so images are included; I've tested this) so long as it is within the X number of <p> tags you specified.

You can style the look of these search results either by creating a component specially for the page or using Special Pages and styling it from that plugin.

Hope this works for you!
Reply
#5
Angryboy Wrote:(% searchresults tags="_parent_SLUG" numWords="Xp" %)

I am getting "no results found."
Reply
#6
4 questions then:
  • What plugins do you have installed?
  • What settings do you have for your parent page(s)?
  • What is the navigational structure of your parent/child pages?
  • What is the exact content that you have pasted onto the parent page(s)?
Reply
#7
List of plugins installed:

DynPages
FAQ
I18N Base
I18N Custom Fields
I18N Gallery
I18N Navigation
I18N Search
Innovation Theme Settings
News Manager
p01-contact
Excerpts
Sitemap

what setting do you have for the parent page?
Didn't quite understand this one.

What is the navigational structure of your parent/child pages?
parent page
- child page1
- child page2
- child page3

What is the exact content that you have pasted onto the parent page(s)?
(% searchresults tags="_parent_writeups" numWords="2p" %)
Reply
#8
Thanks for giving me all this information. I've set up a fresh install of GetSimple with the latest versions of all of these plugins just to see what happens, but I still have not encountered this problem. By any chance, are you using the latest version of I18N Search (since the _parent_ functionality was added to the most recent update)?
Reply
#9
Great. My search version was older. Now it works. How do I remove the words 'Search Results' and 'en' from the displayed results.

I understand I can remove the bullets through css styling. But I also need to remove the words 'search results' and 'en'.

[EDIT] Solved it through the following css.

ul.search-results {list-style:none;margin:0;padding:0;}
li.search-entry {clear:both;list-style:none;}
.search-header {display:none;}
.search-entry-language {display:none;}
Reply
#10
But now there is a new problem. With the page excerpts there was a 'more' link at the end of the text, letting viewers know that they need to click on a link to read more text. With the search results approach, there is nothing in the text to let the viewers know that there is more article to be viewed.
Reply
#11
andyash Wrote:How do I remove the words 'Search Results' and 'en' from the displayed results.

Code:
(% searchresults tags="_parent_writeups" numWords="2p" HEADER="" showLanguage=0 %)
All parameters are listed in Plugins/Configure I18N Search/Usage.
You can also globally switch off showLanguage in Plugins/Configure I18n Search/Settings.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#12
andyash Wrote:But now there is a new problem. With the page excerpts there was a 'more' link at the end of the text, letting viewers know that they need to click on a link to read more text. With the search results approach, there is nothing in the text to let the viewers know that there is more article to be viewed.

With custom rendering you can do this. Create a component and give it the following code:

Code:
<h3 class="search-entry-title">
  <?php if ($showLanguage) { ?>
  <span class="search-entry-language">
    <?php echo htmlspecialchars($item->language, ENT_NOQUOTES); ?>
  </span>
  <?php } ?>
  <a href="<?php echo $item->link; ?>">
    <?php echo htmlspecialchars($item->title, ENT_NOQUOTES); ?>
  </a>
</h3>
<?php if ($showDate) { ?>
<div class="search-entry-date">
  <?php echo strftime($dateFormat, $item->pubDate); ?>
</div>
<?php } ?>
<div class="search-entry-excerpt">
  <?php echo $item->getExcerpt($item->content, $numWords); ?>
</div>
<div class="search-entry-more"><a href="<?php echo $item->link; ?>">...more</a></div>

Then within your (% %) brackets, paste

Code:
component="COMPONENTSLUG"

With the component slug being the exact slug of the component you just defined (as a piece of advice, avoid having spaces and capital letters in your slug since that can introduce problems sometimes).

You can add virtually anything you want within the component to be displayed per-search-result. For example if you wanted to have a piece of information from a Customfield of yours, simply use:

<?php echo $item->fieldname; ?>


or

<?php echo htmlspecialchars($item->fieldname, ENT_NOQUOTES); ?>
, depending on which one suits your needs. Have a fiddle around with the markup of your component until you've got what you are looking for.
Reply
#13
andyash Wrote:But now there is a new problem. With the page excerpts there was a 'more' link at the end of the text, letting viewers know that they need to click on a link to read more text. With the search results approach, there is nothing in the text to let the viewers know that there is more article to be viewed.

Using numWords="2pm" will add "..." (but no link - the user needs to click on the header of the item):
Code:
(% searchresults tags="_parent_writeups" numWords="2pm" HEADER="" showLanguage=0 %)
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#14
Quote:(% searchresults tags="_parent_writeups" numWords="2pm" HEADER="" showLanguage=0 %)
not working.
Reply
#15
Angryboy Wrote:With custom rendering you can do this. Create a component and give it the following code:

Code:
<h3 class="search-entry-title">
  <?php if ($showLanguage) { ?>
  <span class="search-entry-language">
    <?php echo htmlspecialchars($item->language, ENT_NOQUOTES); ?>
  </span>
  <?php } ?>
  <a href="<?php echo $item->link; ?>">
    <?php echo htmlspecialchars($item->title, ENT_NOQUOTES); ?>
  </a>
</h3>
<?php if ($showDate) { ?>
<div class="search-entry-date">
  <?php echo strftime($dateFormat, $item->pubDate); ?>
</div>
<?php } ?>
<div class="search-entry-excerpt">
  <?php echo $item->getExcerpt($item->content, $numWords); ?>
</div>
<div class="search-entry-more"><a href="<?php echo $item->link; ?>">...more</a></div>

Then within your (% %) brackets, paste

Code:
component="COMPONENTSLUG"

With the component slug being the exact slug of the component you just defined (as a piece of advice, avoid having spaces and capital letters in your slug since that can introduce problems sometimes).

You can add virtually anything you want within the component to be displayed per-search-result. For example if you wanted to have a piece of information from a Customfield of yours, simply use:

<?php echo $item->fieldname; ?>


or

<?php echo htmlspecialchars($item->fieldname, ENT_NOQUOTES); ?>
, depending on which one suits your needs. Have a fiddle around with the markup of your component until you've got what you are looking for.

This worked well. Thanks.
Reply
#16
No problem *thumbs up* If you want to make any more changes to the displaying of your results but are unsure of how exactly, feel free to ask.
Reply
#17
Thanks. will do.
Reply




Users browsing this thread: 2 Guest(s)