Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Blog System: Include an image in the home page section

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 02-25-2019, 01:26 AM
 
welly welly is offline
 

eXpert
  
Join Date: Mar 2011
Location: UK
Posts: 209
 

Default Blog System: Include an image in the home page section

Hi all

I am using the XC Blog System plugin for WordPress, which displays excerpts of the latest blog posts on my home page.

By default, those posts are displayed in a fairly unattractive manner, so to try and jazz it up a little, so I have created a module and AWidget.php file with a version of the getHTMLContentWidget() function. Because of the way this function displays the posts, I don't believe it is possible to do what I want through CSS alone.

Although my design skills are a bit rubbish, my module seems to be working, and I can modify the display of posts as I see fit through this function backed up with CSS.

I would like to include the post image in this display too, but as far as I am aware, the image is not available by default. There is certainly no reference to it in the function I am tinkering with, and I don't know how to get it, but I assume it is not part of the data query for the posts.

If you have done this already, or you happen to know how it can be done, can you give me some pointers? I can muddle through most things once I have a basic understanding, but I am not a php programmer. Keeping it simple would be extremely helpful.

Many thanks

Welly
__________________
X-Cart Business 5.3.6
Various add-ons

www.traininglines.co.uk
Reply With Quote
  #2  
Old 02-26-2019, 02:51 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: Blog System: Include an image in the home page section

Hi Welly,

I have just tried to create a blog post with the featured image and this featured image is already displayed alongside the post like this:
https://www.awesomescreenshot.com/image/3887474/324fb1774dbd2714f3254193592400b1

Could you please let me know what kind of image is not yet displayed, but it should be?

Thank you.

Tony
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
  #3  
Old 02-26-2019, 03:13 AM
 
welly welly is offline
 

eXpert
  
Join Date: Mar 2011
Location: UK
Posts: 209
 

Default Re: Blog System: Include an image in the home page section

Hi Tony

Many thanks for your reply.

In the blog page itself, the header images are displayed perfectly. I think that is what your image is showing.

However, I have the content section enabled on my home page, and this content section does not display an image. It only displays, and can only display (as far as I can tell), the heading, the excerpt, and the author for the last few posts.

For every post excerpt I display on my home page, I want to also display the corresponding header image.

I have attached two images. One shows what I created in XC4 using xCMS (Smack Digital), and the other shows what I have done so far with XC5 and the Blog System module. Formatting and layout aside, you can see that in the XC4 version, each post shows the image, and that is what I want to create in XC5.

I just don't know how to obtain the image so that I can display and style it.

EDIT: Somehow my image names are incorrect - the one that shows the images is in XC4, and the one without is XC5. Clever of me...

Many thanks

Welly
Attached Thumbnails
Click image for larger version

Name:	blogXC4.PNG
Views:	296
Size:	32.1 KB
ID:	5308  Click image for larger version

Name:	blogXC5.PNG
Views:	303
Size:	142.7 KB
ID:	5309  
__________________
X-Cart Business 5.3.6
Various add-ons

www.traininglines.co.uk
Reply With Quote
  #4  
Old 03-05-2019, 03:33 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: Blog System: Include an image in the home page section

Hi @welly,

As far as I can see, you can pull post's image from WP using the 'get_the_post_thumbnail' method:
https://developer.wordpress.org/reference/functions/get_the_post_thumbnail/

In that sense, you can edit
Code:
\XLite\Module\QSL\WordPress\View\Plugins\RecentPosts\AWidget
class and define your own version of the getHTMLContentWidget() method which is responsible for displaying the menu widget.

I have just quickly tried to replace this piece of code:
Code:
echo '<h5 class="entry-title"><a href="' . get_permalink() . '" rel="bookmark">' . get_the_title() . '</a></h5>';

with the next one:
Code:
echo '<h5 class="entry-title"><a href="' . get_permalink() . '" rel="bookmark">' . get_the_title() . '</a></h5>'; echo get_the_post_thumbnail();

and it has kind of worked out.

Let me know if you need any further help.

Tony

Quote:
Originally Posted by welly
I have attached two images. One shows what I created in XC4 using xCMS (Smack Digital), and the other shows what I have done so far with XC5 and the Blog System module. Formatting and layout aside, you can see that in the XC4 version, each post shows the image, and that is what I want to create in XC5.

I just don't know how to obtain the image so that I can display and style it.
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
  #5  
Old 03-05-2019, 05:49 AM
 
welly welly is offline
 

eXpert
  
Join Date: Mar 2011
Location: UK
Posts: 209
 

Default Re: Blog System: Include an image in the home page section

Hi Tony

Yes, I think this will do the trick.

That function gets the post 'Featured Image', which I haven't used so far, but it does work. I just need to place the image and finesse it with css, and we should be good to go.

Many thanks

Welly
__________________
X-Cart Business 5.3.6
Various add-ons

www.traininglines.co.uk
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 02:17 AM.

   

 
X-Cart forums © 2001-2020