Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
i want to add li element to this page,
this website was done by someone else
the index.php file include several php files, along with them main.php.
this is the code for main.php
<div class="center"><p class="text3"><?php echo LABEL_TXT_FORNT_PAGE_TITLE;?></p>
<div class="netw"><div>
<div class="title"><?php echo LABEL_TXT_KDMATY;?></div></div>
<p><img src="img/<?php echo $dir;?>/1.jpg" border='1' alt="img" /></p>
<p class="text1"><?php echo TXT_CONTANT_FOR_KDAMATY;?> </p>
<p class="text2"></p>
</div>
<div class="suppserv"><div>
<div class="title"><?php echo LABEL_TXT_CHECK_PRINTING;?></div></div>
<p><img src="img/<?php echo $dir;?>/2.jpg" border='1' alt="img" /></p>
<p class="text1"><?php echo TXT_CONTANT_FOR_PRINT;?>
</p>
<p class="text2"></p></div>
<div class="remote"><div>
<div class="title"><?php echo LABEL_TXT_POINT_OF_SALES;?></div></div>
<p><img src="img/<?php echo $dir;?>/3.jpg" border='1' alt="img" /></p>
<p class="text1"><?php echo TXT_CONTANT_FOR_SALES;?></p>
<p class="text2"></p></div>
</div>
<div class="line"><img src="img/12.png" alt="img" /></div>
<div class="center2">
<div class="netw">
<p class="text4"><?php echo LABEL_TXT_EXPER;?></p>
<p class="text5"><?php echo TXT_CONTANT_EXPER;?></p>
<ul>
<li><?php echo UL_EXPER_EX1;?></li>
<li><?php echo UL_EXPER_EX2;?></li>
<li><?php echo UL_EXPER_EX3;?></li>
<li><?php echo UL_EXPER_EX4;?></li>
<li><?php echo UL_EXPER_EX5;?></li>
</ul>
<p class="text2"><a href="<?php echo SITE_URL; ?>/expertise.php"><?php echo
LABEL_TXT_MORE_LINKS;?><img alt="img" src="img/<?php echo $dir;?>/11.png"></a></p>
<div class="clear"></div>
</div>
<div class="remote">
<p class="text4"><?php echo LABEL_TXT_CUSTOMER;?></p>
<p class="text5"><?php echo TXT_CONTANT_CUSTOMER;?></p>
<ul>
<li><?php echo UL_CUSTOMER_EX1;?></li>
<li><?php echo UL_CUSTOMER_EX2;?></li>
<li><?php echo UL_CUSTOMER_EX3;?></li>
<li><?php echo UL_CUSTOMER_EX4;?></li>
<li><?php echo UL_CUSTOMER_EX5;?></li>
</ul>
</div>
<div class="suppserv">
<p class="text4"><?php echo LABEL_TXT_OUR_SERVICES;?></p>
<p class="text5"><?php echo TXT_CONTANT_SERVICES;?></p><br />
</div>
</div>
note this line :
<li><?php echo UL_CUSTOMER_EX1;?></li>
can someone explain to me what is this, it is not variable and not a constant, so what is it ?
You can define constants in php like this
define("MY_VARIABLE", 6)
And then access anywhere on the script:
echo MY_VARIABLE; // print 6
Is the same that LABEL_TXT_OUR_SERVICES
This is a constant, note that it hasn't the dollar sign before.
Refer to this http://php.net/manual/pt_BR/function.define.php
That constant was declared by using
define("UL_CUSTOMER_EX1", 'some_value_or_var');
Variables' first character is $ sign in PHP.
$var1 = 0; //this is a variable
define('CONST', 100); // is a constant
You can use $var1 and CONST in the page with one difference: $var1's value may be changed programatically but constansts no. Value of CONST cannot change during the execution of the script
That there is a constant. It must have been define()'d somewhere previously, possibly in an included file.
If I were you, I'd search for any define() statements that contain UL_CUSTOMER_EX1.
Yes, i agree with everybody else's opinion: it's a constant defined inside one of the included files.
BUT!
There might be another possibility, which may be probable if the original author is a novice developer:
an UNDEFINED constant, being treated as a string by default from php without warnings enabled.
Because, in PHP, if you use a constant which is undefined, it is reverted to a string which contains the constant name (eg: UNK_CONST becomes the string "UNK_CONST"). Of course it gives a warning too, but warnings may have been suppressed.
Related
How to give the content of $topic_image to a variable like this at the source part?
The problem is here: --> src="image/<?php echo $topi_image?>" .
$display_content=<<<END_OF_TEXT
<div>
<img src="image/<?php echo $topic_image ?>" style="width:200px;height:150px;">
<p style="float:left">$topic_pris</p>
<p style="float:left">$topic_title</p>
<p style="float:left">$topic_name</p>
</div>
END_OF_TEXT;
Heredoc expands variables itself. You don't need the whole <?php echo $topic_image ?>, just the variable:
$display_content=<<<END_OF_TEXT
<div>
<img src="image/${topic_image}" style="width:200px;height:150px;">
<p style="float:left">$topic_pris</p>
<p style="float:left">$topic_title</p>
<p style="float:left">$topic_name</p>
</div>
END_OF_TEXT;
This error makes no sense. Here is the code block and my explanation below.
<?php foreach($rows as $value): ?>
<?php echo $value['authorname'] . "<br />\n";?>
<?php echo $value['title'] . "<br />\n";?>
<?php echo $value['rating'] . "<br />\n";?>
<?php echo $value['imagelocation'] . "<br />\n";?>
<div class="block">
<div class="row">
<div class="col-md-4 col-md-8">
<div class="widget-block">
<input id="rate1" value="<?php echo $value['rating'];?>" type="number" class="rating" data-max="5" data-min="0" data-size="sm" data-show-clear="false" readOnly="readOnly">
<img class="img-responsive wow fadeInLeftBig animated" data-wow-duration="1.5s" src=<?php echo $value['$imagelocation'];?> alt=<?php echo $value['$authorname'];?>>
<br>
Buy this book
</div>
</div>
<div class="col-md-6 col-md-8">
<div class="section-sub-title">
<article class="section-title-body white">
<h1 class="head-title">Author: <span><?php echo $value['$authorname'];?> -</span> <?php echo $value['$title'];?></h1>
<span class="point-line hidden-xs hidden-sm"></span>
<p>
<?php echo $value['$review'];?>
</p>
</article>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
The echo statements right after the start of the foreach loop prints out each variable fine. It isn't until we get down to the html that there are issues.
This code feeds an array of data from a DB then builds blocks of html code depending on the amount of data. In this case, I am pulling 8 records so this loop creates 8 copies of this code block. The thing that is frustrating is the variable "$rating" injects in all 8 blocks but none of the other variables do even though they print correctly on the page in the echo statements.
Maybe it is the data in the variable? For example as the code is parsed the first variable evaluated is $rating and works. The next one is the src property in the img tag $imagelocation and has an actual value of img\book_covers\TrueConviction.jpg
Are _ and . special characters and causing the issue? My return values would have _ . \ and spaces.
Thanks for any help.
I was right that it was the data IN the variables. The answer was urldecode. This solved my problems. I did this to all my variables.
$cleanauthorname = urldecode($value['authorname']);?>
I'm working on this (NSFW), I created 12 subpages but only 10 are showing in the list.
I'm not using any limit() or pagination() in the snippet nor in the panel config, I can't find where this limit is regulated. My guess is a numbering issue, because if in the panel I drag up the 11th subpage up, anything below will not be displayed.
Any clue?
php:
<section id="entries">
<ul>
<li>
<div class="line asger">
<div class="text">00</div>
<div class="text bold">Asger Carlsen</div>
</div>
</li>
<?php $n = 1; foreach($pages->children()->visible()->sortBy('date', 'asc') as $entries): ?>
<li>
<div class="line">
<div class="text">0<?php echo $n++; ?></div>
<div class="table"><div class="text bold"><?php echo kirbytext($entries->title()) ?></div></div>
<div class="text"><?php echo kirbytext($entries->kind()) ?></div>
</div>
<div class="description hidden">
<?php echo kirbytext($entries->description()) ?>
</div>
<div class="left-half">
<img class="images hidden" src="<?php echo $entries->images()->first()->url() ?>" alt="<?php echo html($entries->title()) ?>" />
</div>
</li>
<?php endforeach ?>
</ul>
</section>
Folder structure: https://www.dropbox.com/s/8gigspwup0kwqei/Screenshot%202014-09-03%2015.39.51.png?dl=0
Your folder-structure is defiantly correct. You only could try to rename 04-2001 to something like 04-foo2001 but i don`t think that this causes your issue.
I had some quite similar behavior once. It was caused by image-metadata txt's that had the same name like the page-content txt's. So maybe it would be helpful if you show us your complete folder-structure including the files/filenames.
Next idea: Are you sure you have no invalid markdown in your txt's?
PS: This should be a comment, but i’m at 49 reputation, so i’m not allowed to comment ;) cheers!
It was probably a combination of .txt name conflict plus a missing image from a page.
I've already been searching for a couple of hours for a solution. What I want to do is make icons that don't got a value (in the php) not show up.
Here's an image of what I currently have.
So for instance if only twitter and facebook got values, they should only appear on the screen.
Below is the code, and I hope someone got a solution for this.
Cheers!
<ul class="social-buttons">
<div class="wrapping">
<a class="social" href="http://twitter.com/<?php echo $profile_data['twitter']; ?>" target="_blank"><li class="twitter"></li></a>
<a class="social" href="http://facebook.com/<?php echo $profile_data['facebook']; ?>" target="_blank"><li class="facebook"></li></a>
<a class="social" href="skype:<?php echo $profile_data['skype']; ?>?chat"><li class="skype"></li></a>
<a class="social" href="http://instagram.com/<?php echo $profile_data['instagram']; ?>"><li class="instagram"></li></a>
<a class="social" href="http://dribbble.com/<?php echo $profile_data['dribbble']; ?>"><li class="dribbble"></li></a>
<a class="social" href="http://linkedin.com/in/<?php echo $profile_data['linkedin']; ?>"><li class="linkedin"></li></a>
</div>
</ul>
You need to use the if statement with !empty(). The !empty() checks if a variable is NOT empty. Than proceed with the code. Like the example given here:
<?php
if(!empty($profile_data['twitter'])){
?>
<a class="social" href="http://twitter.com/<?php echo $profile_data['twitter']; ?>" target="_blank"><li class="twitter"></li></a>
<?php
}
?>
If the variable is empty, it wont give the outputed code, in your case the <a> with the icon.
i think you can do like:
<ul class="social-buttons">
<div class="wrapping">
<?php if $profile_data['twitter'] {?>
<a class="social" href="http://twitter.com/<?php echo $profile_data['twitter']; ?>" target="_blank"><li class="twitter"></li></a>
<?php } ?>
....
</ul>
Imo, a probably better way to do this is to perform a pre-processing of the data i.e. $profile_data, before you use it in your view so the view would no longer need to handle the processing logic. After which, the view can output your links by using a more concise construct e.g. for loop, that does not use any conditional branching.
I'm attempting to modify an app for facebook that uses php and javascript.
It allows a user to send gifts to each other's wall. When a gift is received, it show's on the app's notification page for that user.
The problem: after a gift is accepted, it still shows on the notifications page. I suppose because it was deemed necessary in order for the point system as well as the history functions to operate properly. It appears that gifts older than 30 days are no longer displayed. I tried to permanently change the date of the gift after it's accepted.
Can anyone please suggest possible ways to:
Option 1. After the gift is accepted, permanently change it to a different image to inform the user "you have already accepted this". Without removing it from the database.
Option 2. Remove the gift from the page (or prevent it from being displayed) after it's accepted...without deleting it from the database. .hide and display:none; are not viable options because the gift will be displayed again...every time the page loads.
Option 3. Last and least desired option, remove the gift from the page and database as well.
The original code for that page is below. The part of the code that I'm guessing needs to be modified is located between the asterisk dividers. I hope it's not too difficult to follow :-/
Thanks for your time.
<?php
if(!isset($facebook))
{
$user_id=$_POST['user_id'];
}
else
{
$user_id=$user_info['UserID'];
}
$news_limit=$current_time-2592000;
$history_query=mysql_query("SELECT * FROM ".$exchange_table." WHERE Time>'$news_limit'
AND ReceiverID='$user_id' ORDER BY Time DESC");
$history_num=mysql_num_rows($history_query); ?>
<div style="font-size:14px;width:720px;padding:10px;<?php echo $background_one; ?>"
align="left">
<div style="font-weight:bold;font-size:16px;color:#6f6f6f;">
<?php echo $nav_info['home']; ?>
</div>
<div style="width:100%;margin-top:10px;" align="center">
<img src="<?php echo $app_info['image_url']; ?>divider.gif">
<img src="<?php echo $app_info['image_url']; ?>divider.gif">
<img src="<?php echo $app_info['image_url']; ?>divider.gif">
</div> <?php
if($history_num>0)
{
$gift_query=mysql_query("SELECT GiftID,Name,Image FROM ".$gift_table." WHERE
Type='1'");
while($gift_info=mysql_fetch_assoc($gift_query))
{
$gift_array[$gift_info['GiftID']]['name']=$gift_info['Name'];
$gift_array[$gift_info['GiftID']]['image']=$gift_info['Image'];
} ?>
<div style=""> <?php
$i=1;
while($history_info=mysql_fetch_assoc($history_query))
{ ?>
<div style="margin-top:10px;">
<div style="float:left;width:75px;">
<img src="<?php echo
$app_info['upload_url'].$gift_array[$history_info['GiftID']]['image']; ?>"
style="width:75px;height:75px;">
</div>
<div style="float:left;margin-left:10px;">
<span style="font-size:18px;"><span id="month<?php echo $i; ?>"></span> -
Gift Received!</span><br>
You received a(n) <b><?php echo $gift_array[$history_info['GiftID']]
['name']; ?></b> from <b><fb:name uid='<?php echo $history_info['FacebookID']; ?>'
linked='false'></fb:name></b>!<br>
**************************************************************
<input id="share_button<?php echo $i; ?>" onclick="shareFeed('<?php echo
$gift_array[$history_info['GiftID']]['image']; ?>','<?php echo $history_info['GiftID'];
?>','<?php echo $gift_array[$history_info['GiftID']]['name']; ?>')" type="image" src="
<?php echo $app_info['image_url']; ?>share_button.png"
onmouseover="convert('share_button<?php echo $i; ?>','share_hover.png')"
onmouseout="convert('share_button<?php echo $i; ?>','share_button.png')"
style="height:29px;margin-top:5px;">
</div>
**************************************************************
<br style="clear:both;">
</div>
<script>
var date_text="";
var time_date=new Date();
var monthNames=
["January","February","March","April","May",
"June","July","August","September","October","November","December"];
time_date.setTime(<?php echo $history_info['Time']*1000; ?>);
document.getElementById('month<?php echo $i; ?
>').innerHTML=monthNames[time_date.getMonth()]+" "+time_date.getDate();
</script> <?php
$i++;
} ?>
</div> <?php
}
else
{ ?>
<div style="font-size:14px;font-weight:bold;margin-top:20px;" align="center">
No giftss received over the past 30 days.
</div> <?php
} ?>
</div>