vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Sidebar Block CMS Article - Image instead of avatar (https://vborg.vbsupport.ru/showthread.php?t=273444)

killer_t 11-05-2011 07:59 PM

Sidebar Block CMS Article - Image instead of avatar
 
Hi at all.

I have the sidebar in forum with CMS article.
Now i see the avatar of the publisher, but i want see the image of the article..

This is what you have to do :

1- Edit block_cmsarticles to call the image instead of avatar :

Code:

<li>
        <div class="block smaller">
                <div class="blocksubhead">
                        <a class="collapse" id="collapse_block_cmsarticles_{vb:raw blockinfo.blockid}" href="{vb:raw relpath}#top"><img alt="" src="{vb:stylevar imgdir_button}/collapse_40b.png" id="collapseimg_cmsarticles_{vb:raw blockinfo.blockid}"/></a>
                        <img src="{vb:stylevar imgdir_cms}/widget-article.png" alt="" />
                        <span class="blocktitle">{vb:raw blockinfo.title}</span>
                </div>
                <div class="widget_content blockbody floatcontainer">
                <ul id="block_cmsarticles_{vb:raw blockinfo.blockid}" class="blockrow">
                        <vb:each from="articles" key="articleid" value="article">
                        <li class="noavatarcontent floatcontainer widget_post_bit">
                                <div class="widget_post_userinfo"></div>
<vb:if condition="$article['previewimage']">
<img alt="previewimage" src="{vb:raw article.previewimage}"  with="150" height="150" />
</vb:if>

                                <div class="smallavatartext widget_post_comment_noavatar">
                                        <h5 class="widget_post_header"><a href="{vb:raw article.url}" class="title">{vb:raw article.title}</a></h5>
                                        <p class="widget_post_content">{vb:raw article.message}</p>
                                        <div class="meta">
                                                <vb:if condition="$articlestype == 0">
                                                {vb:stylevar dirmark}(1{vb:rawphrase x_comments, {vb:raw article.replycount}})
                                                </vb:if>
                                        </div>
                                </div>
                        </li>
                        </vb:each>
                </ul>
                </div>
        </div>
        <div class="underblock"></div>
</li>

- 2 Edit file /includes/blocks/cmsarticles.php and around line 160 include cms_article.previewimage in order to be able to recall the variable in the template:

Code:


$results = $this->registry->db->query_read_slave("
        SELECT cms_article.contentid, cms_article.pagetext as message,
                    cms_article.previewimage, cms_article.previewvideo,
                    cms_node.nodeid, cms_node.url, cms_node.publishdate,
                    cms_nodeinfo.title,
                    thread.replycount, thread.lastpost as lastpostarticle, thread.lastposter, thread.lastpostid, thread.lastposterid,
                                user.*
                                " . ($this->registry->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight" : "") . "
                        FROM " . TABLE_PREFIX . "cms_article AS cms_article
                        INNER JOIN " . TABLE_PREFIX . "cms_node AS cms_node ON (cms_node.contentid = cms_article.contentid)
                        INNER JOIN " . TABLE_PREFIX . "cms_nodeinfo AS cms_nodeinfo ON (cms_nodeinfo.nodeid = cms_node.nodeid)
                        $catjoin
                        LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON (cms_nodeinfo.associatedthreadid = thread.threadid)
                        LEFT JOIN " . TABLE_PREFIX . "user AS user ON (cms_node.userid = user.userid)
                        " . ($this->registry->options['avatarenabled'] ? "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)" : "") . "
                        WHERE 1=1
                                $sectionidsql
                                $catidsql
                                AND cms_node.setpublish = 1
                                AND cms_node.publishdate <= " . TIMENOW . "
                                AND cms_node.publicpreview = 1
                                $datecutoffsql
                        ORDER BY$ordersql
                        LIMIT 0," . intval($this->config['cmsarticles_limit']) . "
                ");

                require_once(DIR . '/includes/class_bootstrap_framework.php');
                vB_Bootstrap_Framework::init();

That's all. Now you are able to use image instead of avatar.
Remeber to clear cms cache after you apply your modify.

Demo here (my site)

killer_t 11-08-2011 08:20 AM

Nobody can Help me??

killer_t 11-10-2011 09:06 PM

:(
Please help me
:(

Lynne 11-10-2011 09:19 PM

You need to modify the query $results in /includes/blocks/cmsarticles.php around line 160 to include cms_article.previewimage in order to be able to use it in the template.

killer_t 11-11-2011 08:28 AM

I had already tried this way, but doesn't work.

Lynne 11-11-2011 05:50 PM

Please post your exact changes so we can try it ourselves.

killer_t 11-11-2011 07:05 PM

I tried and tried and it works!
I do not know what I did but now it works. And it works thanks to your code. Thank you Lynne!

Lynne 11-11-2011 07:38 PM

You probably didn't Clear CMS cache after making the changes and so it was still showing the cached widget.

killer_t 11-11-2011 08:12 PM

I think you're right! Thanks Lynne!

killer_t 12-09-2011 10:54 AM

where you stop?

Lynne 12-09-2011 04:09 PM

Quote:

Originally Posted by lightbox (Post 2276150)
Would you be so nice as to share the necessary changes?
I would like to do the same.

Thanks,
Martin

The changes are posted already in the first post and in the fourth post.

killer_t 12-09-2011 05:36 PM

I've edited the first post with instruction. Hope this help you!

Lynne 12-09-2011 05:38 PM

If you want the widget to be changed permanently, then yes, you would need to put the suggestion into the tracker over on vbulletin.com

illkeyone 12-12-2011 10:13 PM

I'd like to see attachment images in the RECENT THREADS widget. So, when someone posts a message to a specific forum, the attached image will be shown in the home page.

- Is this also possible? :( -- considering I'm not a coder :/

killer_t 12-12-2011 10:39 PM

what kind of attachments?

afcbob 05-15-2012 11:13 AM

Hi i have tried this and reset cache here is a link to my forum www.carswapped.co.uk

Any help would be great.

Lynne 05-15-2012 04:56 PM

Latest Swaps is still obviously showing avatars. We can't help troubleshoot this if you don't post *exactly* what you have done.

afcbob 05-16-2012 01:26 PM

I have done what is in the first post but never worked for some reason

kh99 05-16-2012 01:31 PM

I believe the instructions in the first post are for modifying a CMS widget to display article images. It looks like what you have is a forum block, so those changes wouldn't work for you.

Edit: But I'm wrong, see below.

afcbob 05-16-2012 02:07 PM

Was chat Lynne and she was telling me about how to change the block images thought it was this one she is going on about.

Is there away to get it to work on the forum block

Lynne 05-16-2012 04:00 PM

The stuff in the first post is specific to the block of type "CMS Articles". If you are doing this for a different block type, then you need to apply similar changes to the appropriate template and file for the block you are trying to modify. So, if that is what you are doing, then post your block type and the exact files and templates you are changing along with what you changed.

kh99 05-16-2012 04:05 PM

Quote:

Originally Posted by Lynne (Post 2329906)
The stuff in the first post is specific to the block of type "CMS Articles".

Oops...I was wrong. Sorry about that.

afcbob 05-16-2012 05:40 PM

It was a forum thread block, its just the default template and changed the same files thats on the first page.

Lynne 05-16-2012 08:52 PM

Quote:

Originally Posted by afcbob (Post 2329962)
It was a forum thread block, its just the default template and changed the same files thats on the first page.

And, as I already said, you CANNOT change the same files as in the first page because that is for a different block. You need to edit the appropriate file (/includes/block/threads.php) and the appropriate template (block_threads) for what you are doing.

johnnymc7 06-17-2012 05:50 PM

I followed all instructions and Im getting no joy :-/

--------------- Added [DATE]1339960543[/DATE] at [TIME]1339960543[/TIME] ---------------

In my recent articles block on the front page all that is happening is the avatar has disappeared


block_cmsarticles
Code:

<li>
        <div class="block smaller">
                <div class="blocksubhead">
                        <a class="collapse" id="collapse_block_cmsarticles_{vb:raw blockinfo.blockid}" href="{vb:raw relpath}#top"><img alt="" src="{vb:stylevar imgdir_button}/collapse_40b.png" id="collapseimg_cmsarticles_{vb:raw blockinfo.blockid}"/></a>
                        <img src="{vb:stylevar imgdir_cms}/widget-article.png" alt="" />
                        <span class="blocktitle">{vb:raw blockinfo.title}</span>
                </div>
                <div class="widget_content blockbody floatcontainer">
                <ul id="block_cmsarticles_{vb:raw blockinfo.blockid}" class="blockrow">
                        <vb:each from="articles" key="articleid" value="article">
                        <li class="noavatarcontent floatcontainer widget_post_bit">
                                <div class="widget_post_userinfo"></div>
<vb:if condition="$article['previewimage']">
<img alt="previewimage" src="{vb:raw article.previewimage}"  with="250" height="250" />
</vb:if>
                                <div class="smallavatartext widget_post_comment_noavatar">
                                        <h5 class="widget_post_header"><a href="{vb:raw article.url}" class="title">{vb:raw article.title}</a></h5>
                                        <p class="widget_post_content">{vb:raw article.message}</p>
                                        <div class="meta">
                                                <vb:if condition="$articlestype == 0">
                                                {vb:stylevar dirmark}(1{vb:rawphrase x_comments, {vb:raw article.replycount}})
                                                </vb:if>
                                        </div>
                                </div>
                        </li>
                        </vb:each>
                </ul>
                </div>
        </div>
        <div class="underblock"></div>
</li>

and in includes/block/cmsarticles.php

Code:

$results = $this->registry->db->query_read_slave("
                        SELECT cms_article.contentid, cms_article.pagetext as message,
                                cms_article.previewimage, cms_article.previewvideo,
                                cms_node.nodeid, cms_node.url, cms_node.publishdate,
                                cms_nodeinfo.title,
                                thread.replycount, thread.lastpost as lastpostarticle, thread.lastposter, thread.lastpostid, thread.lastposterid,
                                user.*
                                " . ($this->registry->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight" : "") . "
                        FROM " . TABLE_PREFIX . "cms_article AS cms_article


Lynne 06-17-2012 11:55 PM

Can we get a link to see the problem?

johnnymc7 06-24-2012 08:20 PM

Sorry Lynne in my delaying in replying to you. Heres my site http://www.irishdrumandbass.com/content.php as you can see the article block is at the bottom with no images for any of the articles

Thanks

John

Lynne 06-25-2012 02:36 AM

I don't think you have edited the correct template (or else I am not looking at the correct style). This is in the page source where the image should be:

HTML Code:

                        <div class="cms_widget_post_bit widget_post_bit">
                                <div class="cms_widget_post_userinfo widget_post_userinfo">
                                        <div class="cms_widget_post_useravatar widget_post_useravatar">
                                               
                                                        <img alt="" src="images/misc/unknown.gif" />
                                               
                                        </div>
                                </div>
                                <div class="cms_widget_post_comment widget_post_comment">

None of that is in the template code you posted above.

johnnymc7 06-25-2012 07:22 AM

Hi Lynne, thanks for the reply.

I only have one style its the default style with some changes. Ive edited block_cmsarticles in vbulletin and then I edited /includes/block/cmsarticles.php in my text editor. I can see all edits when I look there so Im really confused :(

Lynne 06-25-2012 03:12 PM

Do this - vboptions > General Settings > Add Template Name in HTML Comments > set to Yes . Then go back to your page and view the source code and you will see the name of the template called around that part of the code. What is the template name that surrounds that widget?

Then

johnnymc7 06-25-2012 06:05 PM

This is what I got when I did that Lynne

Quote:

<!-- BEGIN TEMPLATE: vbcms_widget_recentarticle_page -->
<div class="cms_widget">
<div class="block">
<div class="cms_widget_header">
<h3><img alt="" src="images/cms/widget-forum.png" /> Recent Articles</h3>
</div>
<div class="cms_widget_content widget_content">

<div class="cms_widget_post_bit widget_post_bit">
<div class="cms_widget_post_userinfo widget_post_userinfo">
<div class="cms_widget_post_useravatar widget_post_useravatar">

<img alt="" src="images/misc/unknown.gif" />

</div>
</div>
<div class="cms_widget_post_comment widget_post_comment">

<h4 class="cms_widget_post_header widget_post_header"><a href="http://www.irishdrumandbass.com/content.php?125-Pessimist">Hertz-U Presents Pessimist 29/06/12</a></h4>

<div class="cms_widget_post_content widget_post_content"><br />
<br />
Hertz-U Soundsystem are back after a brilliant night at Fierce in April and after upsetting the neighbours... <a href="http://www.irishdrumandbass.com/content.php?125-Pessimist">read more</a></div>

<a href="http://www.irishdrumandbass.com/content.php?125-Pessimist" class="lastpostdate understate" title="Go to last post"></a>



<div class="searchstats">
<h4 class="searchlastpostlabel">Categories: </h4>

<a href="http://www.irishdrumandbass.com/list.php?category/43-News">News</a>&nbsp;

</div>



</div>

</div>

</div>
</div>
</div>
<!-- END TEMPLATE: vbcms_widget_recentarticle_page --></li>

<!-- END TEMPLATE: vbcms_widget_column --></ul>
Thanks for all the help!

Lynne 06-25-2012 10:59 PM

Then this is the template you needed to modify - vbcms_widget_recentarticle_page . Your's is a cms widget. This thread started out talking about forum blocks. So, you will need to make the appropriate changes to the widget code and widget templates, not the block code and block templates.

johnnymc7 06-26-2012 05:12 PM

Hi Lynne sorry I took this up wrong. I found code that Dead Eddie put up and it was exactly what I was looking for. Thanks for all your help :-)

schneberger 11-01-2014 12:49 AM

i can see there is a typ in the first post.

the width option is written as with instead of width.

and also if you put in the variables width="100%" and leave out the height option. then your images fits perfectly in the sidebar

like this.

http://motorcyclebuilders.net/forum.php

tbworld 11-01-2014 01:02 AM

Quote:

Originally Posted by johnnymc7 (Post 2343102)
Hi Lynne sorry I took this up wrong. I found code that Dead Eddie put up and it was exactly what I was looking for. Thanks for all your help :-)

Please post a link to the post you found from @Dead_Eddie, as this may be useful to others that are following this thread. Thank You, :)


All times are GMT. The time now is 07:52 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01306 seconds
  • Memory Usage 1,844KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (1)bbcode_html_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (35)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete