CakePHP custom setFlash - php

I've read on the CakePHP Book that you can define your own custom setFlash messages using an element... but what I would I put inside the element and how would I pass different content.
So for example two different messages:
<div id="flashMessage" class="message">
<div class="content">
<p>Please correct the errors</p>
</div>
</div>
<div id="flashMessage" class="announcement message">
<div class="content">
<h3>Announcement</h3>
<p>You have earned a new achievement</p>
</div>
</div>
So as you can see I want to define a wrapper div and a content div and then also pass in an additional class if need be dependant on the kind of message and also show different content such as just a paragraph or a header and a paragraph.
Can anyone help? Thanks

You can have two elements:
myflash.ctp
<div id="flashMessage" class="message">
<div class="content">
<p><? echo $message ?></p>
</div>
</div>
announcement.ctp
<div id="flashMessage" class="announcement message">
<div class="content">
<h3>Announcement</h3>
<p><? echo $message ?></p>
</div>
</div>
and then:
$this->Session->setFlash($message,'myflash or announcement');
or one element:
myflash.ctp
<div id="flashMessage" class="<? echo (isset($myclass)?$myclass.' ':'') ?>message">
<div class="content">
<? echo (isset($header)?'<h3>' . $header.'</h3>':'') ?>
<p><? echo $message ?></p>
</div>
</div>
and at your controller:
$this->Session->setFlash($message,'myflash',array('myclass'=>'announcement','header'=>'Announcement');

Related

ACF Group type not working and the if inside PHP tag hide the section1 in the front end

<?php $section1 = get_field('section1'); ?>
<div class="section1" id="section1">
<div class="container">
<h2><?php echo $section1['title']; ?></h2>
<div class="quote-triangle">
<p>
<?php echo $section1['quote']; ?>
</p>
<div class="quote__moving-border"></div>
</div>
<div class="bottom">
<div data-aos="fade-down">
<div class="leftside">
<h3>
<?php echo $section1['title_image']; ?>
</h3>
<div class="caption"><?php echo $section1['caption_image']; ?></div>
<div class="desc">
<p>
<?php echo $section1['desc_image']; ?>
</p>
</div>
</div>
</div>
<div data-aos="fade-down">
<div class="rightside">
<img src="<?php echo esc_url( $secttion1['image']['url'] ); ?>" alt="" class="rightside__img">
</div>
</div>
</div>
</div>
</div>
<?php endif; ?>
I had followed literally the ACF documentation for the GROUP type but when I put the if in the PHP tag the whole section disappears and when I remove if the section back but The Group type still not worked.

How to remove unwanted break in bootstrap panel

I have panel where I'm displaying some basic informations about user. I want to display graph in the center of this panel.
I have problems with one unwanted space which I want to remove but I don't know how to do it.
Please look at image:
Code for this panel:
<div class="row">
<div class="panel panel-default">
<div class="panel-heading">Detail zákazníka </div>
<div class="panel-body">
<div class="form-group">
<label>ID zákazníka:</label>
<p><?php echo !empty($zakaznici['ID_zakaznici'])?$zakaznici['ID_zakaznici']:''; ?></p>
</div>
<div class="form-group">
<label>Meno:</label>
<p><?php echo !empty($zakaznici['meno'])?$zakaznici['meno']:''; ?></p>
</div>
<div class="panel-body" align="center">Graph will be displayed here</div>
<div class="form-group">
<label>Priezvisko:</label>
<p><?php echo !empty($zakaznici['priezvisko'])?$zakaznici['priezvisko']:''; ?></p>
</div>
<div class="form-group">
<label>Email:</label>
<p><?php echo !empty($zakaznici['email'])?$zakaznici['email']:''; ?></p>
</div>
<div class="form-group">
<label>Adresa:</label>
<p><?php echo !empty($zakaznici['adresa'])?$zakaznici['adresa']:''; ?></p>
</div>
<a class="btn btn-primary" href="<?php echo site_url('Zakaznici/viewusersvypozicky/'.$zakaznici['ID_zakaznici']); ?>" role="button">Zobraziť prenájmy</a>
</div>
</div>
</div>
p tags create line breaks. You could replace the p tag with a span tag to remove the unwanted break.
Your div with the class name 'panel-body' is also occupying space. You could add position: absolute; to its defined styles and it would not create that break.
<div class="row">
<div class="panel panel-default">
<div class="panel-heading">Detail zákazníka </div>
<div class="panel-body">
<div class="form-group">
<label>ID zákazníka:</label>
<p><?php echo !empty($zakaznici['ID_zakaznici'])?$zakaznici['ID_zakaznici']:''; ?></p>
</div>
<div class="form-group">
<label>Meno:</label>
<span><?php echo !empty($zakaznici['meno'])?$zakaznici['meno']:''; ?></span>
</div>
<div class="panel-body" align="center">Graph will be displayed here</div>
<div class="form-group">
<label>Priezvisko:</label>
<p><?php echo !empty($zakaznici['priezvisko'])?$zakaznici['priezvisko']:''; ?></p>
</div>
<div class="form-group">
<label>Email:</label>
<p><?php echo !empty($zakaznici['email'])?$zakaznici['email']:''; ?></p>
</div>
<div class="form-group">
<label>Adresa:</label>
<p><?php echo !empty($zakaznici['adresa'])?$zakaznici['adresa']:''; ?></p>
</div>
<a class="btn btn-primary" href="<?php echo site_url('Zakaznici/viewusersvypozicky/'.$zakaznici['ID_zakaznici']); ?>" role="button">Zobraziť prenájmy</a>
</div>
</div>
</div>
Try this
<div class = "row">
<div class = "panel panel-default col-4">
<div class = "panel-body">
//your matter
</div>
</div>
<div class = "panel panel-default col-4">
<div class = "panel-body">
//your graph
</div>
</div>
</div>
As discussed the p's are block level elements and create linebreaks - but Bootstrap also stlyes them with a 10px margin bottom so you may want to overwrite that with
p { margin-bottom: 0;}
I do not recommend this - the ideaa of the margin bottom is to separate text elements.
What will be causing your space issue where you have indicated is that you are using a div with a .panel body class within the panel body.
<div class="panel-body" align="center">Graph will be displayed here</div>
Bootstrap styles the panel body with 15px padding - so either
a) replace that class with a different class (this is what I would do - it makes no sense to have a .panel-body -within a .panel-body)
b) remove the padding from the nested panel body
.panel-body > .panel-body { padding: 0}
But as I said - a panel body within another one is semantically wrong.

Trying to add default text to show before called header text

Trying to add default text (LEARN MORE:) in same h5 heading just before the called get_the_title hook.
what shows now example:
MLS# T3110937 9313 MANDRAKE CT, TAMPA, FL 33647
Example of adding LEARN MORE: always being added before the called title hook:
LEARN MORE: MLS# T3110937 9313 MANDRAKE CT, TAMPA, FL 33647
Here is the code I am working with:
<div class="overlay">
<div class="container">
<h1><?php echo balanceTags($title);?></h1>
<li>
<div class="pull-left"><?php echo balanceTags($title);?> </div>
<h5>
<div style="text-align: center;">
<?php echo get_the_title();?>
</div>
</h5>
</li>
</div>
</div>
I think what you are looking for is
<div style="text-align: center;">
<?php echo 'Learn More: ' . get_the_title();?>
</div>
To concatenate in php, add a . between two or more output variables.
You can also put the text on the outside of the PHP tag.
<div style="text-align: center;">
Learn More: <?php echo get_the_title();?>
</div>
Try this, I think you also need the permalink on that text.
<div class="overlay">
<div class="container">
<h1><?php echo balanceTags($title);?></h1>
<div class="pull-left"><?php echo balanceTags($title);?></div>
<h5 style="text-align: center;">
<?php the_title(); ?> Learn More
</h5>
</div>
</div>
Also give a bounce to this:
https://developer.wordpress.org/reference/functions/the_permalink/

Wordpress - How to use Ajax Load More plugin

I'm developing a website in wordpress and I want to load more news when scrolling but I already have a html structure and when I put ajax load more it put own structure and I don' want that.
I'm using the Ajax Load More plugin.
So, How can I use Ajax load more with this html structure:
<?php
$posts = get_posts(['cat' => get_cat_ID("news")]);
foreach($posts as $post){
setup_postdata($post);
?>
<div class="col-xs-12 col-sm-6 col-md-4">
<a class="news-link" href="<?php the_permalink() ?>">
<div class="news">
<div class="image">
<?php the_post_thumbnail('thumbnail') ?>
<div class="mask">
<div class="icon">
<i class="icon-plus"></i>
</div>
</div>
</div>
<div class="title">
<span>
<?php the_title(); ?>
</span>
</div>
<div class="excerpt">
<p class="date">
<?php echo get_the_date('Y-m-d'); ?>
</p>
</div>
<div class="excerpt">
<p>
<?php the_excerpt(); ?>
</p>
</div>
</div>
</a>
</div>
<?php
wp_reset_postdata();
} ?>
If i put this shortcode it shows but not with the structure that i want.
[ajax_load_more id="7279302844" container_type="div" post_type="post" category="news"]
Thank you

Jump to next section in while loop

OK, this is a bit complicated so Ill try my best to explain it:
I have a while loop which has a next link, before I just had it in standard html, so it was farely simple, on click of the class 'arrow' it would just to the next section e.g:
$i = 0;
while ( have_rows('sections') ) : the_row();
$sectionName = $i++;
?>
<section id="<?php echo $sectionName; ?>" class="full-bg-image" style="background-image: url('<?php the_sub_field('section_image'); ?>')">
<div class="image divider" id="partnersImg" style="background-image: url('<?php the_sub_field('section_image'); ?>')">
<div class="wrapper">
<div class="overlay" style="color: <?php the_field('section_text_colour','options'); ?>">
<?php the_sub_field('divider_text'); ?>
</div>
</div>
</div>
<div class="sectionContent">
<div class="wrapper">
<div class="centerContent">
<div class="contentWrapper">
<div class="text animation-element" data-sr="enter center wait 0.5s, no reset" style="background-color: <?php the_field('text_block_bg_colour','options'); ?>; color: <?php the_field('text_block_text_colour','options'); ?>">
<?php the_sub_field('section_text'); ?>
<div class="arrowContainer"></div>
</div>
<div class="clr"></div>
</div>
</div>
</div>
</div>
</section>
<?php endwhile;
The sectionName variable is set for each item name that is added in the wordpress admin however the issue comes when my above code shows and the anchor is linking too itself and not the next section, I would like to know how to link it to the next section and if its the last section then to have a anchor which links to the first.
<section id="0">
<div class="arrowContainer"></div>
</section>
<section id="1">
<div class="arrowContainer"></div>
</section>
<section id="2">
<div class="arrowContainer"></div>
</section>
<section id="3">
<div class="arrowContainer"></div>
</section>
In this case I am using Advanced Custom Fields repeater and not posts.

Categories