<![CDATA[ NewsListing with preview image? - My Forums]]> https://forums.modx.com/thread/?thread=33422 <![CDATA[NewsListing with preview image?]]> https://forums.modx.com/thread/33422/newslisting-with-preview-image?page=2#dis-post-183821 The NewsListing snippet would have to be coded to recognize the summary tv field
People, pls help with tuning the NewsListing snippet :!:]]>
bugaev Apr 21, 2005, 01:46 PM https://forums.modx.com/thread/33422/newslisting-with-preview-image?page=2#dis-post-183821
<![CDATA[NewsListing with preview image?]]> https://forums.modx.com/thread/33422/newslisting-with-preview-image?page=2#dis-post-183820
Ok, the code I showed you only works with the native summary field. It will not work the the TV fields. Future versions of such snippets will most likely support TV fields

So is the problem with MODx or NewsListing snippet? I'm sure that richtext summary field is a HOT topic :!: Of course you may insert an image html-code in a plain-text field, but it is not comfortable at all :? .
The NewsListing snippet would have to be coded to recognize the summary tv field]]>
xwisdom Apr 21, 2005, 03:30 AM https://forums.modx.com/thread/33422/newslisting-with-preview-image?page=2#dis-post-183820
<![CDATA[NewsListing with preview image?]]> https://forums.modx.com/thread/33422/newslisting-with-preview-image#dis-post-183819 Ok, the code I showed you only works with the native summary field. It will not work the the TV fields. Future versions of such snippets will most likely support TV fields
So is the problem with MODx or NewsListing snippet? I'm sure that richtext summary field is a HOT topic :!: Of course you may insert an image html-code in a plain-text field, but it is not comfortable at all :? .]]>
bugaev Apr 21, 2005, 01:06 AM https://forums.modx.com/thread/33422/newslisting-with-preview-image#dis-post-183819
<![CDATA[NewsListing with preview image?]]> https://forums.modx.com/thread/33422/newslisting-with-preview-image#dis-post-183818 sottwell Apr 20, 2005, 06:29 PM https://forums.modx.com/thread/33422/newslisting-with-preview-image#dis-post-183818 <![CDATA[NewsListing with preview image?]]> https://forums.modx.com/thread/33422/newslisting-with-preview-image#dis-post-183817 In my current version of MODx native summary field works fine and it is displaying in the NewsListing. But when I move summary content to the introtext-TV it is not displaying. Instead the first XXX letters of the article appear.

I'm using MODx+bugfx downloaded from http://www.sottwell.com/downloads/ a few weeks ago. But today I've found that this site had changed it's skin (now it is green, not blue as a few weeks ago). So it seems I have not the last version of MODx. Xwisdom, may be you could send me the last version?

Ok, the code I showed you only works with the native summary field. It will not work the the TV fields. Future versions of such snippets will most likely support TV fields


P.S. By the way, I've translated MODx lang-file on russian and can share it.

Sounds great! You can post it inside the forums

Thank you for use MODx

Best regards,]]>
xwisdom Apr 20, 2005, 04:30 PM https://forums.modx.com/thread/33422/newslisting-with-preview-image#dis-post-183817
<![CDATA[NewsListing with preview image?]]> https://forums.modx.com/thread/33422/newslisting-with-preview-image#dis-post-183816
I'm using MODx+bugfx downloaded from http://www.sottwell.com/downloads/ a few weeks ago. But today I've found that this site had changed it's skin (now it is green, not blue as a few weeks ago). So it seems I have not the last version of MODx. Xwisdom, may be you could send me the last version?

P.S. By the way, I've translated MODx lang-file on russian and can share it.]]>
bugaev Apr 20, 2005, 02:50 PM https://forums.modx.com/thread/33422/newslisting-with-preview-image#dis-post-183816
<![CDATA[NewsListing with preview image?]]> https://forums.modx.com/thread/33422/newslisting-with-preview-image#dis-post-183815
Are you using a TV introtext field or the Summary field on the document page?

If you should enter some text inside the Summary field of the document it should be displayed.

This line checks for it :

if(strlen($resource[$x]['introtext'])>0) {]]>
xwisdom Apr 20, 2005, 10:18 AM https://forums.modx.com/thread/33422/newslisting-with-preview-image#dis-post-183815
<![CDATA[NewsListing with preview image?]]> https://forums.modx.com/thread/33422/newslisting-with-preview-image#dis-post-183814
I've changed the snippet code exactly as you say, but the introtext content doesn't display by NewsListing snippet :? The snippet shows only truncate text of the articles.

Coud you check up my code:

$resourceparent = isset($newsid) ? $newsid : $etomite->documentIdentifier;
         // the folder that contains blog entries 
$output = '';
         // initialise the blog variable 
$nrblogs = 2;
         // nr of blogs to show a short portion of 
$nrblogstotal = 100;
         // total nr of blogs to retrieve 
$lentoshow = 550;
         // how many characters to show of blogs 



$resource = $etomite->getAllChildren($resourceparent, 'createdon', 'DESC', $fields='id, pagetitle, description, introtext, content, createdon, createdby');



$limit=count($resource);
if($limit<1) { 
   $output .= "No entries found.<br />"; 
} 
$nrblogs = $nrblogs<$limit ? $nrblogs : $limit; 
if($limit>0) { 
   for ($x = 0; $x < $nrblogs; $x++) { 
	  $tbl = $this->dbConfig['dbase'].".".$this->dbConfig['table_prefix']."manager_users";
      $sql = "SELECT username FROM $tbl WHERE $tbl.id = ".$resource[$x]['createdby']; 
      $rs2 = $etomite->dbQuery($sql);
      $limit2 = $etomite->recordCount($rs2); 
      if($limit2<1) { 
         $username .= "anonymous"; 
      } else { 
         $resourceuser = $etomite->fetchRow($rs2); 
         $username = $resourceuser['username']; 

	 
// show summary
if(strlen($resource[$x]['introtext'])>0) {
$rest = $resource[$x]['introtext'];
if(strlen($resource[$x]['content'])>0) $rest ."...<br />    <a href='[~".$resource[$x]['id']."~]'>More on this story ></a>";
} else if(strlen($resource[$x]['content'])>$lentoshow) {
// strip the content
$rest = substr($resource[$x]['content'], 0, $lentoshow);
$rest .= "...<br />    <a href='[~".$resource [$x]['id']."~]'>More on this story ></a>";
} else {
$rest = $resource[$x]['content'];
}
 
		 
		 
         $output .= "<fieldset><legend>".$resource[$x]['pagetitle']."</legend>".$rest."<br /><div style='text-align:right;'>Author: <b>".$username."</b> on ".strftime("%d-%m-%y %H:%M:%S", $resource[$x]['createdon'])."</div></fieldset>"; 
      } 
   } 
} 

if($limit>$nrblogs) { 
   $output .= "<br /><br /><b>Older news</b><br />"; 
   for ($x = $nrblogs; $x < $limit; $x++) { 
      $output .= "> <a href='[~".$resource[$x]['id']."~]'>".$resource[$x]['pagetitle']."</a><br />";          
   } 
}

return $output;
]]>
bugaev Apr 20, 2005, 09:04 AM https://forums.modx.com/thread/33422/newslisting-with-preview-image#dis-post-183814
<![CDATA[NewsListing with preview image?]]> https://forums.modx.com/thread/33422/newslisting-with-preview-image#dis-post-183813
As I understand that I need to create the new template variable with richtext input type and append the introtext field from my MySQL-database. And then to modify NewsListing snippet in order to display the content of the introtext field.

Well you could create a new TV with richtext input called introtext. This will overwrite the existing introtext or summary field. You would have to modify the existing NewListing snippet to use TV functions


Xwisdom, please :roll: , could you tell me how to do it in a 1-2-3 manner?

This will work without the creating a new TV

In the original newslisting snippet change modify line 20 to show:

$resource = $modx->getAllChildren($resourceparent, 'createdon', 'DESC', $fields='id, pagetitle, description, introtext, content, createdon, createdby');


Note the "introtext" as added to the above

then change lines 35-41 from:

         // strip the content 
         if(strlen($resource[$x]['content'])>$lentoshow) { 
            $rest = substr($resource[$x]['content'], 0, $lentoshow); 
            $rest .= "...<br />    <a href='[~".$resource[$x]['id']."~]'>More on this story ></a>"; 
         } else { 
            $rest = $resource[$x]['content']; 
         } 


to

		// show summary
		if(strlen($resource[$x]['introtext'])>0) {
            $rest = $resource[$x]['introtext'];
			if(strlen($resource[$x]['content'])>0) $rest .= "...<br />    <a href='[~".$resource[$x]['id']."~]'>More on this story ></a>"; 
		} else if(strlen($resource[$x]['content'])>$lentoshow) { 
			// strip the content 
            $rest = substr($resource[$x]['content'], 0, $lentoshow); 
            $rest .= "...<br />    <a href='[~".$resource[$x]['id']."~]'>More on this story ></a>"; 
        } else { 
            $rest = $resource[$x]['content']; 
        } 


This will allow you to use the document's summary (introtext) field with HTML syntax for news summary headers. If no summary is available it will use a portion of the content field as it would normally.

That's it!]]>
xwisdom Apr 19, 2005, 09:39 AM https://forums.modx.com/thread/33422/newslisting-with-preview-image#dis-post-183813
<![CDATA[NewsListing with preview image?]]> https://forums.modx.com/thread/33422/newslisting-with-preview-image#dis-post-183812
As I understand that I need to create the new template variable with richtext input type and append the introtext field from my MySQL-database. And then to modify NewsListing snippet in order to display the content of the introtext field.

Xwisdom, please :roll: , could you tell me how to do it in a 1-2-3 manner?]]>
bugaev Apr 19, 2005, 07:08 AM https://forums.modx.com/thread/33422/newslisting-with-preview-image#dis-post-183812