Jump to content

How to make a custom block showing an image?

Featured Replies

Posted

I like to add a latest entries block for 3 IP content database on one of the page: https://carnity.com/updates/ but I like to show an image along with a title. Is it possible...?

Thanks in advance.

Capture.JPG

create the database feed block you want then edit and go to "Content"  click on  "Use this template as-is Use as a base for a custom template"  and then add this on top or somewhere of the database template you created 

<p align="center"><a><img src="IMAGE LINK" alt="hellshammers" width="290" height="160"></a></p>

 

  • Author

Thanks Mr nice guy, I tried couple of images link option but failed as I'm not having a programmer head. Can you please advise from attach what should be the IMAGE LINK....? for advice: https://carnity.com/advice/ Thanks in advance.

Capture.JPG

  • Author

Here is the advice_new block codes:

{{if !empty( $records ) }}
<h3 class='ipsWidget_title ipsType_reset'>{lang="block_latest_records" sprintf="$database->recordWord( 2, TRUE )"}</h3>
	{{if $orientation == 'vertical'}}
		<div class='ipsPad_half ipsWidget_inner'>
			<ul class='ipsDataList ipsDataList_reducedSpacing'>
				{{foreach $records as $record}}
					<li class='ipsDataItem'>
						<div class='ipsDataItem_icon ipsPos_top'>
							{template="userPhoto" group="global" app="core" params="$record->author(), 'tiny'"}
						</div>
                      		<div class='ipsDataItem_main'>
							<div class="ipsCommentCount ipsPos_right {{if ( $record->record_comments ) === 0}}ipsFaded{{endif}}" data-ipsTooltip title='{lang="replies_number" pluralize="$record->record_comments"}'>{expression="$record->record_comments"}</div>
							<a href="{$record->url()->setQueryString( 'do', 'getLastComment' )}" title='{lang="view_this_cmsrecord" sprintf="\IPS\Member::loggedIn()->language()->addToStack( 'content_db_lang_sl_' . $record::$customDatabaseId, FALSE ), $record->_title"}' class='ipsDataItem_title ipsType_break'>{wordbreak="$record->_title"}</a><br>
							<span class='ipsType_light ipsType_small'>{lang="byline_nodate" htmlsprintf="$record->author()->link()"} · {datetime="$record->mapped('date')"}</span>
						</div>
					</li>
				{{endforeach}}
			</ul>
		</div>
	{{else}}
		<div class='ipsWidget_inner'>
			<ul class='ipsDataList'>
				{template="recordRow" group="listing" location="database" app="cms" themeClass="IPS\cms\Theme" params="null, null, $records"}
			</ul>
		</div>
	{{endif}}
{{endif}}

 

  • Author

OK, but then how images will be displayed dynamically, as this block will keep getting updated almost every few hours....?

An image field’s full URL can be used in any Pages template (including blocks) like this:

{file="$record->field_XXX" extension="cms_Records"}

XXX ist the field ID. 

For the main record image, you don’t even need an ID. It’s just:

{file="$record->record_image" extension="cms_Records"}

 

  • Author

Thanks opentype, your suggestion worked great for latest advices that uses single upload image (default IPB field).

Now Im stuck with latest classifieds and business listing that is using multiple images in custom image field: https://carnity.com/classy/

Can anyone please advise how to alter below line of code for showing only one of multiple uploaded images....?

Codes for advise:

<p align="center"><a><img src="{file="$record->record_image" extension="cms_Records"}" alt="carnity" width="290" height="160"></a></p>

Codes for classifieds and business listings:

Business listing code
<p align="center"><a><img src={$record->customFieldDisplayByKey('bl_company_images', 'display')|raw}</a></p>

Classifieds code
<p align="center"><a><img src={$record->customFieldDisplayByKey('images', 'display')|raw}</a></p>

 

Archived

This topic is now archived and is closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.