Notice

The forum is in read only mode.

Support Forum

Welcome! Support Forums have been reactivated
Welcome the Technical Support section. Help us in assisting you by providing us with a concise and descriptive elaboration of your issues. Be specific and if possible, provide us with a step-by-step instruction in replicating your problem.

How to replace hero image with own module?

6 years 2 months ago
  • Michał's Avatar
    Topic Author
  • Michał
  • Offline
  • Moderator
  • Posts: 13447
  • Thank you received: 3689
Licenses:

I was asked to prepare a snippet that allows to add anything else (e.g text, own photo or video) in hero image position. Final effect look like this: prntscr.com/4ls9p9 So it requires styling :)

Cod allows you to add own module that will replace hero image but also removes "Join us!" button... so it's recommended to have other registration button on site... or maybe you have suggestion where to move it?

Snippet is posted below.


- Instead of saying: 'it's not working', explain the problem in detail.
- Screenshots with the URL visible in them and the problem marked are more than welcome.
- Tell us how to replicate the problem, we can't fix it if we can't find it.
- Make sure that your site/server meets JomSocial System Requirements
- Make sure to setup JomSocial Cron Job
- Always provide us with access details to the backend and ftp. We need it to debug problems.
- If you have a similar problem, but a solution you found isn't working, open a new thread instead of 'merging' with an existing one.

- Use the "Thank You" feature on any post that helped you
6 years 2 months ago
  • Michał's Avatar
    Topic Author
  • Michał
  • Offline
  • Moderator
  • Posts: 13447
  • Thank you received: 3689
Licenses:

You need to copy this file:

ROOT/components/com_community/templates/default/frontpage.guests.php

to:

ROOT/templates/your-template/html/com_community (if you don't have "html" or "com_community" folders, feel free to create them).

Then edit file and replace this (starting from line 22 up to line 53:

<div class="row-fluid hero-area">
	<div class="hero-area-wrapper">
		<img class="hero-area-bg" src="<?php echo $heroImage; ?>"></img>

		<div class="content hidden-phone">
			<h1><?php echo JText::_('COM_COMMUNITY_GET_CONNECTED_TITLE'); ?></h1>
			<div class="content-cta">
				<div class="row-fluid">
					<div class="span7">
						<p><?php echo JText::_('COM_COMMUNITY_HERO_PARAGRAPH'); ?></p>
					</div>
					<div class="span4 offset1">
						<?php if ($allowUserRegister) : ?>
						<a class="btn btn-block btn-large btn-primary" href="<?php echo CRoute::_( 'index.php?option=com_community&view=register' , false ); ?>">
							<?php echo JText::_('COM_COMMUNITY_JOIN_US_NOW'); ?>
						</a>
						<?php endif; ?>
					</div>
				</div>
			</div>
		</div>

		<div class="content visible-phone">
			<?php if ($allowUserRegister) : ?>
			<a class="btn btn-block btn-large btn-primary" href="<?php echo CRoute::_( 'index.php?option=com_community&view=register' , false ); ?>">
				<?php echo JText::_('COM_COMMUNITY_JOIN_US_NOW'); ?>
			</a>
			<?php endif; ?>
		</div>

	</div>
</div>

with this:
<div class="row-fluid hero-area">
	<?php if($moduleCount > 0) { ?>
		<div class="hero-area-wrapper-module">
			<?php $this->renderModules('my_frontpage_module'); ?>
		</div>
	<?php } else { ?>
	<div class="hero-area-wrapper">
		<img class="hero-area-bg" src="<?php echo $heroImage; ?>"></img>

		<div class="content hidden-phone">
			<h1><?php echo JText::_('COM_COMMUNITY_GET_CONNECTED_TITLE'); ?></h1>
			<div class="content-cta">
				<div class="row-fluid">
					<div class="span7">
						<p><?php echo JText::_('COM_COMMUNITY_HERO_PARAGRAPH'); ?></p>
					</div>
					<div class="span4 offset1">
						<?php if ($allowUserRegister) : ?>
						<a class="btn btn-block btn-large btn-primary" href="<?php echo CRoute::_( 'index.php?option=com_community&view=register' , false ); ?>">
							<?php echo JText::_('COM_COMMUNITY_JOIN_US_NOW'); ?>
						</a>
						<?php endif; ?>
					</div>
				</div>
			</div>
		</div>

		<div class="content visible-phone">
			<?php if ($allowUserRegister) : ?>
			<a class="btn btn-block btn-large btn-primary" href="<?php echo CRoute::_( 'index.php?option=com_community&view=register' , false ); ?>">
				<?php echo JText::_('COM_COMMUNITY_JOIN_US_NOW'); ?>
			</a>
			<?php endif; ?>
		</div>

	</div>
	<?php } ?>
</div>

And add this code in line 11 (right under defined('_JEXEC') or die(); located in line 10):
$moduleCount = count(JModuleHelper::getModules('my_frontpage_module'));

How does it work?

There is code that counts modules in certain position.
Then I created a condition if there is more than 0 modules assigned to position "my_frontpage_module". If yes, module is loaded and hero image is gone. If no modules are assigned - hero image is displayed.

You can replace "my_frontpage_module" position name with your own (remember to do it in all 3 places in code).

When assigning module to position, you'll need to type module position name as it will be not listed.

Code snippet is for JomSocial 3.2.1.4.


- Instead of saying: 'it's not working', explain the problem in detail.
- Screenshots with the URL visible in them and the problem marked are more than welcome.
- Tell us how to replicate the problem, we can't fix it if we can't find it.
- Make sure that your site/server meets JomSocial System Requirements
- Make sure to setup JomSocial Cron Job
- Always provide us with access details to the backend and ftp. We need it to debug problems.
- If you have a similar problem, but a solution you found isn't working, open a new thread instead of 'merging' with an existing one.

- Use the "Thank You" feature on any post that helped you
The following user(s) said Thank You: P. Irion
6 years 2 months ago
  • Michał's Avatar
    Topic Author
  • Michał
  • Offline
  • Moderator
  • Posts: 13447
  • Thank you received: 3689
Licenses:

If some of you have troubles with applying my hack - here is a demo file.


- Instead of saying: 'it's not working', explain the problem in detail.
- Screenshots with the URL visible in them and the problem marked are more than welcome.
- Tell us how to replicate the problem, we can't fix it if we can't find it.
- Make sure that your site/server meets JomSocial System Requirements
- Make sure to setup JomSocial Cron Job
- Always provide us with access details to the backend and ftp. We need it to debug problems.
- If you have a similar problem, but a solution you found isn't working, open a new thread instead of 'merging' with an existing one.

- Use the "Thank You" feature on any post that helped you

This message has an attachment file.
Please log in or register to see it.

The following user(s) said Thank You: P. Irion, Susan
Moderators: Piotr Garasiński
Powered by Kunena Forum

Join 180,000 websites creating Amazing communities

JomSocial is the most complete, easy-to-use addon that turns Joomla CMS into a
full -fledged, social networking site

TRY NOW BUY NOW