Here is the code I have:
in the php file:
if($special>0){
$lease_price = (($special/1000)*38);
} else {
$lease_price = (($price/1000)*38);
}
$lease_price = $this->currency->format($lease_price);
and in the front end tpl file:
<p>
<i class="fa fa-chevron-down"></i>
<b>Lease To Buy Price:</b>
<span><?php if($price>500){ ?>
<?php echo $lease_price; ?>
<?php } else { echo 'NA'; } ?></span>
</p>
Now I believe this works, but I think I'm entering the php code in the wrong area of the php document which is causing the variable $lease_price to not work.
Here's a link to a pastebin of my php file, where would I enter the code above? http://pastebin.com/bTPtvgUQ
Thanks for the help
Related
<?php
$name = "{{t_33}}";
$y=$name;
for($i=$y;$i<24;$i++) { ?>
<li>
<a class="<?php
if (($i>0 and $i<4) || ($i>20 and $i<24)) echo 'dark';
else if (($i>3 and $i<8)|| ($i>16 and $i<21)) echo 'light';
else if ($i>7 and $i<17) echo ''; ?>"
href="#">
<?php echo $i; ?>
</a>
<?php if($i==1) { ?>
<h4>{{day}}</h4>
<?php } ?>
</li>
<?php } ?>
The issue is that I am getting the value in $name but when I assign it in $y and try to use it in for loop the page goes blank. Please help.
I think that issue is with order of processing your code. You should know that php is interpreted on server side and javascript is procesed on client side.
Now when your angular is code running, php functions are already processed. (I'm simplyfing here ofc.)
I searched for a solution, but I dont finde something suitable. I use the following script part to login/logout at my wordpress website:
<?php if (is_user_logged_in()) { ?>
<span>Logout</span> <-- works -->
<?php } else { get_template_part('ajax', 'auth'); ?>
<a id="show_login" href=""><span>Login</span></a>
<?php } ?>
If I modify the first part (wp_logout_url) into html it will not work:
<?php if (is_user_logged_in()) { ?>
<a id="show_profile" href=""><span>Profile </span></a> <-- dont work -->
<?php } else { get_template_part('ajax', 'auth'); ?>
<a id="show_login" href=""><span>Login </span></a>
<?php } ?>
Why html works only at the login part? I´ve done a php error?
There is no link inside the "href", because its fireing the lightbox.
UPDATE:
I found out, that the problem will be the "get_template_part", this is requiered to load the content inside the lightbox .. but I dont know how to integrate it in the first part correctly.
I'm attempting to add social follow icons to a BuddyPress site using a section of code that I found here:
https://buddypress.org/support/topic/display-users-social-follow-buttons-in-profile/
I followed the suggestion downthread and added the code to a bp-custom.php file in my plugins directory and the icons are showing up where they should but the link to the social profile is showing as text and when I click on the link it returns a 404 page.
I'm sure I have something wrong but I'm just too clueless new to spot it.
<?php
//Social Media Icons based on the profile user info
function member_social_extend(){
$dmember_id = $bp->displayed_user->id;
$fb_info = xprofile_get_field_data('facebook', $dmember_id);
$google_info = xprofile_get_field_data('googleplus', $dmember_id);
$linkedin_info = xprofile_get_field_data('linkedin', $dmember_id);
$twitter_info = xprofile_get_field_data('twitter', $dmember_id);
echo '<div class="member-social">';
if($fb_info||$google_info||$linkedin_info||$twitter_info){
echo 'My Social: ';
}
if ($fb_info) {
?>
<span class="fb-info"><img src="<?php bloginfo('wpurl'); ?>/wp-content/themes/family-openstrap-child/images/facebook.png" /></span>
<?php
}
?>
<?php
if ($google_info) {
?>
<span class="google-info"><img src="<?php bloginfo('wpurl'); ?>/wp-content/themes/family-openstrap-child/images/googleplus.png" /></span>
<?php
}
?>
<?php
if ($linkedin_info) {
?>
<span class="linkedin-info"><img src="<?php bloginfo('wpurl'); ?>/wp-content/themes/family-openstrap-child/images/linkedin.png" /></span>
<?php
}
?>
<?php
if ($twitter_info) {
?>
<span class="twitter-info"><img src="<?php bloginfo('wpurl'); ?>/wp-content/themes/family-openstrap-child/images/twitter.png" /></span>
<?php
}
echo '</div>';
}
add_filter( 'bp_before_member_header_meta', 'member_social_extend' );
?>
Thanks!
Looks like xprofile_get_field_data() creates its own <a> tag, so you don't have to write one out like you've done there. Try this instead:
$fb_info = xprofile_get_field_data(
'<img src="' . bloginfo('wpurl') . '/wp-content/themes/family-openstrap-child/images/facebook.png" />',
$dmember_id
);
...
<span class="fb-info"><?php echo $fb_info; ?></span>
Not sure if xprofile_get_field_data() will let you pass HTML in the first parameter there, so if that doesn't work quite right, you could fall back to something simpler (no image) like:
$fb_info = xprofile_get_field_data('Facebook', $dmember_id);
Please can someone help me with this. I have this MySQL query which lists users on my site, and echos a link that can be clicked to take you to the user's profile:
<?php
$online_set = online_channel();
while ($online = mysql_fetch_array($online_set)) {
echo "<div class=\"online_row\"><img width=25px height=25px src=\"data/photos/{$online['user_id']}/_default.jpg\" class=\"online_image\"/><div class=\"online_text\">{$online['display_name']}</div></div>";?>
<? } ?>
The link goes to profile.php and echos the users 'user_id' so it knows which users profile to take you to, and now I am wanting to include a session variable in the link somehow so a message is displayed on that users profile after clicking the link.
I have tried including $_SESSION['chat'] in the link but it doesn't work:
<?php
$online_set = online_channel();
while ($online = mysql_fetch_array($online_set)) {
echo "<div class=\"online_row\"><img width=25px height=25px src=\"data/photos/{$online['user_id']}/_default.jpg\" class=\"online_image\"/><div class=\"online_text\">{$online['display_name']}</div></div>";?>
<? } ?>
I am also trying to execute the session in profile.php by using this:
<?
session_start();
if(isset($_SESSION['chat']))
echo $_SESSION['chat']="<div class=\"infobox-favourites\"><strong>Deleted from Favourites</strong> - This user has successfully been deleted from your favourites.</div><div class=\"infobox-close4\"></div>";
unset($_SESSION['chat']);
?>
What I have tried is not working and i'm not sure i'm doing it right, so I would really appreciate any help with this. Thanks
Try this...for easier debugging the entire code you have
<?php
$online_set = online_channel();
while ($online = mysql_fetch_array($online_set)) {
?>
<div class="online_row">
<a href="profile.php?id=<?php echo $online['user_id'];?>">
<img width=25px height=25px src="data/photos/<?php echo $online['user_id'];?>/_default.jpg/" class="online_image" />
<div class="online_text\">
<?php echo $online['display_name'];?>
</div>
</a>
</div>
<?php
}
?>
Just review the code I posted to learn the better way to echo an entire div
I am trying add an if statement to an anchor like so.
<div class="box-button">
<a href="
<?php $header_button = of_get_option('header_text'); ?>
<?php if($header_button){?>
<?php echo of_get_option('header_text'); ?>
<?php } else { ?>
#
<?php } ?>
" class="button">Connect Now</a>
</div>
I can click the button on the homepage and I will get linked to "#" so it is as if wordpress doesn't recognize as a theme option. Is my syntax the problem?
You know you can do the logic outside the html and then insert the result into the href
<?php
$header_button = of_get_option('header_text');
$link = (!empty($header_button)?$header_button:'#');
?>
<div class="box-button">
Connect Now
</div>