I have a php file tab.php which is creating tabs.The code of tab.php is:
<ul id="tabs">
<?php
$tab=' ';
if($tab=='') $tab='setup';
//$tab=$_REQUEST['tab'];
if($tab=='setup'){ ?>
<li><b><span>Setup</span></b></li>
<?php
}else{ ?>
<li><span>Setup</span></li>
<?php } ?>
<?php if($tab=='options'){ ?>
<li><b><span>Options</span></b></li>
<?php }else{ ?>
<li><span>Options</span></li>
<?php } ?>
<?php if($tab=='questions'){ ?>
<li><b><span>Questions</span></b></li>
<?php }else{ ?>
<li><span>Questions</span></li>
<?php } ?>
<?php if($tab=='flow'){ ?>
<li><b><span>Flow</span></b></li>
<?php }else{ ?>
<li><span>Flow</span></li>
<?php } ?>
</ul>
<div style="clear:both; background-color:#edcb27; height:0px; overflow:hidden;"></div>
<div style="border:solid 3px #edcb27; background-color:#edcb27; padding:10px; font-family:Verdana, Geneva, sans-serif; font-size:11px;">
<label>Edit Mode</label>
<label>dfhfghj</label>
I have four php files namely setup.php,options.php,question.php and test.php.What I want is when I click on setup tab setup.php should open.When I click on option.php then my option.php should open and so on.Initially setup.php should be visible.So where should I include my all four php files so that particular php file should be open when clicking on tab?
If your page will be refresh each time when you press a tab you can use a switch statement and get tab value from query-string:
$tab = $_GET["tab"];
switch ($tab) {
case "setup":
require "setup.php";
break;
default:
break;
}
to load a YOUR_FILENAME.php.
Other (good) solution is use a asynchronous request with jQuery or other JavaScript libraries.
Cheers
If you are putting all your tab pages in the same folder as this code, this should do the trick
<ul id="tabs">
<?php
$tab='';
if(!isset($_GET['tab'])) $tab='setup';
else $tab = $_GET['tab'];
//$tab=$_REQUEST['tab'];
if($tab=='setup'){ ?>
<li><b><span>Setup</span></b></li>
<?php
}else{ ?>
<li><span>Setup</span></li>
<?php } ?>
<?php if($tab=='options'){ ?>
<li><b><span>Options</span></b></li>
<?php }else{ ?>
<li><span>Options</span></li>
<?php } ?>
<?php if($tab=='questions'){ ?>
<li><b><span>Questions</span></b></li>
<?php }else{ ?>
<li><span>Questions</span></li>
<?php } ?>
<?php if($tab=='flow'){ ?>
<li><b><span>Flow</span></b></li>
<?php }else{ ?>
<li><span>Flow</span></li>
<?php } ?>
</ul>
<div style="clear:both; background-color:#edcb27; height:0px; overflow:hidden;"></div>
<div style="border:solid 3px #edcb27; background-color:#edcb27; padding:10px; font-family:Verdana, Geneva, sans-serif; font-size:11px;">
<label>Edit Mode</label>
<label>dfhfghj</label>
<!-- assuming you are putting the content of the page here -->
require($tab.'.php');
I'd just do it with if(isset($_GET['setup'])) { display setup code } seems the simple solution to me.
Related
I have a wordpress register.php file from the buddyboss-platform(1.8.5).
And there are all input fields under each other, like this:
Lable Email
Input field email
lable password
input field password
But I want to have them next to each other. Like this
lable Email lable password
input field Email input field password
And of course I tried a lot. And googled a lot. But the input fields stay vertical and not horizontally
So this is the register.php file:
<?php
?>
<?php bp_nouveau_signup_hook('before', 'page'); ?>
<div id="register-page" class="page register-page">
<?php bp_nouveau_template_notices(); ?>
<?php bp_nouveau_user_feedback(bp_get_current_signup_step()); ?>
<form action="" name="signup_form" id="signup-form box" class="standard-form signup-form clearfix" method="post" enctype="multipart/form-data">
<?php if ('request-details' === bp_get_current_signup_step()) : ?>
<?php bp_nouveau_signup_hook('after', 'account_details'); ?>
<div class="register-section default-profile" id="basic-details-section">
<?php /***** Basic Account Details ******/ ?>
</div><!-- #basic-details-section -->
<?php bp_nouveau_signup_hook('after', 'account_details'); ?>
<?php /***** Extra Profile Details ******/ ?>
<?php if (bp_is_active('xprofile') && bp_nouveau_base_account_has_xprofile()) : ?>
<?php bp_nouveau_signup_hook('before', 'signup_profile'); ?>
<div class="register-section extended-profile" id="profile-details-section">
<?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?>
<?php while (bp_profile_groups()) : bp_the_profile_group(); ?>
<?php while (bp_profile_fields()) : bp_the_profile_field();
if (function_exists('bp_member_type_enable_disable') && false === bp_member_type_enable_disable()) {
if (function_exists('bp_get_xprofile_member_type_field_id') && bp_get_the_profile_field_id() === bp_get_xprofile_member_type_field_id()) {
continue;
}
}
?>
<div<?php bp_field_css_class('editfield');
bp_field_data_attribute(); ?> <fieldset>
<?php
$field_type = bp_xprofile_create_field_type(bp_get_the_profile_field_type());
$field_type->edit_field_html();
?>
</fieldset>
</div>
<?php endwhile; ?>
<input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php bp_the_profile_field_ids(); ?>" />
<?php endwhile; ?>
<?php bp_nouveau_signup_form(); ?>
<?php bp_nouveau_signup_hook('', 'signup_profile'); ?>
</div><!-- #profile-details-section -->
<?php bp_nouveau_signup_hook('after', 'signup_profile'); ?>
<?php endif; ?>
</div><!-- //.layout-wrap -->
<?php bp_nouveau_signup_terms_privacy(); ?>
<?php bp_nouveau_submit_button('register'); ?>
<?php endif; // request-details signup step
?>
<?php bp_nouveau_signup_hook('custom', 'steps'); ?>
</form>
</div>
<?php bp_nouveau_signup_hook('after', 'page'); ?>
And I tried this in style.css
#box {
display: flex;
align-items: baseline;
}
#productSearch form input {
vertical-align: middle;
}
But that doesn't worked.
And A side note. I also saw in the downloaded buddyboss-platform that the register.php has after the closing </form> an ending </div>. But without opening div. Is that legal?
My question. What I have to change? So that the two fields will shown horizontal?
This is mostly a CSS issue as buddypress is applying its own style.
Try using this (if it doesn't work, apply a higher specificity):
#basic-details-section {
display: grid;
grid-template-columns: 1fr 1fr;
grid-column-gap: 14px;
}
Higher specificity #register-page #signup-form #basic-details-section
Working with the Kirby CMS, I'm trying to pull all the files of a page and apply different markup to images and videos. In Kirby, there is the $file->type() command, which I think I would have to use in an if-statement in order to distuniguish the files, but my current code is not working. What I tried is this:
<?php
$page = page('PageTitle');
$page_files = $page->files();
?>
<div class="slider-container" id="slider#">
<div class="slider">
<?php foreach($page_files->sortBy('sort', 'asc') as $page_file): ?>
<?php if ($page_file->type() == 'image') { ?>
<div style="background: url('<?= $page_file->url() ?>'); background-size: cover; height: 100vh;"></div>
<?php endif; ?>
<?php endforeach ?>
</div>
</div>
What am I doing wrong?
The answer to my question is a rather obvious one, I made a simple syntactic mistake by using a { instead of : in the first line of the if-statement. This would be the proper, working version of the code, distinguishing between images and videos:
<?php if($file->type() == 'image'): ?>
<!-- markup for image -->
<?php endif ?>
<?php if($file->type() == 'video'): ?>
<!-- markup for video -->
<?php endif ?>
I'm trying to produce list of recently added item in cart and the code goes like this
<ol style = "overflow: -moz-scrollbars-vertical; overflow-y: scroll;">
<?php foreach($_items as $_item): ?>
<?php echo $this->getItemHtml($_item) ?>
<?php endforeach; ?>
</ol>
I'm getting the items but the scroll not working. Please help me. I'm a budding developer.
If you want to have vertical scroll after certain height of ol container use below listed code
<ol style = "overflow-y: scroll;">
use overflow:auto property of css instead of scroll, and give some height for your list.
Specify a height there like this
<ol style = "overflow: -moz-scrollbars-vertical; overflow-y: scroll;height:50px;">
<?php foreach($_items as $_item): ?>
<?php echo $this->getItemHtml($_item) ?>
<?php endforeach; ?>
</ol>
I want to create tabs that function like toggles, but instead only one toggle can be active at one time. The content of the tab also needs to be above the the tabs themselves. The problem is I am using a loop to generate the content as well as the tabs themselves.
I've got a nice javascript code right here that works perfectly fine. I understand this perfectly as well. The only problem is that it obviously doesn't disable other toggles when another one is clicked. Also having one "tab" / "toggle" always active. Code that could probably check the div id with a prefix of "post" and make all div id's with "post" to display:none besides the one that was clicked on. That would be perfect if that could be possible. Another way I could think of this is putting all the generated content into a container, and it simply disables all id's in the container besides the one that was clicked.
If this code can be modified to achieve that, it would be great. This is some very simple code that I understand very clearly. All I need is that it behaves more like tabs where only one can be active at once.
<script type="text/javascript">
function toggleMeMirror(a){
var e=document.getElementById(a);
if(!e) return true;
if(e.style.display=="none"){
e.style.display="inline"
} else {
e.style.display="none"
}
return true;
}
</script>
HTML / PHP
Loop 1 - The Content
<?php while ($queryepisodemirrors->have_posts()) : $queryepisodemirrors->the_post(); ?>
<?php if(get_post_meta(get_the_ID(), 'parentIDmirror', true) == $postIDCheck) { ?>
<div id="post-<?php the_ID(); ?>" style="display:none;">
<center><?php the_title(); ?><br /><br />
<?php echo get_post_meta(get_the_ID(), 'mirror_embed_code', true); ?>
<?php wprp(true);?>
</center>
</div>
<?php } ?>
<?php endwhile; ?>
Loop 2 - The actual toggles / tabs
<?php while ($queryepisodemirrors->have_posts()) : $queryepisodemirrors->the_post(); ?>
<?php if(get_post_meta(get_the_ID(), 'parentIDmirror', true) == $postIDCheck) { ?>
<div style="float: left; padding: 4px;">
<center>
<div class="post-<?php the_ID(); ?>" onclick="return toggleMeMirror('post-<?php the_ID(); ?>')" >
<div style="overflow: hidden; width: 150px; height: 100px;">
<div style="background: rgb(0, 0, 0) transparent; /* fallback color */ background: rgba(0, 0, 0, 0.8); color: white; padding: 2px;">
<center>
<?php echo get_post_meta(get_the_ID(), 'video_provider', true);
echo ' Mirror';?>
</center>
</div>
<img src="<?php echo $thumbnail_src; ?>" width="150px"/>
</div>
</div>
</center>
</div>
<?php } ?>
<?php endwhile; ?>
This is also tagged jquery so I'll just recommend that you include the jquery library and include:
$('.someclass').hide();
as the first line in the toggleMeMirror function.
Then, make sure that each of your looped content divs exist in the class "someclass".
like:
foreach($this as $that) {
print "<div class='someclass'>$that</div>";
}
then
function toggleMeMirror(a){
// hide all
$('.someclass').hide();
// show one
var e=document.getElementById(a);
if(!e) return true;
if(e.style.display=="none"){
e.style.display="inline"
} else {
e.style.display="none"
}
return true;
}
You can try something like this DEMO
HTML Code
<div id="one"><img src='http://img.widgetbox.com/thumbs/302/8fb0669c-72ee-454d-a08f-9700b8a5270a.png?4' height='50px' widht='50px' ></div><br>
<div id="two"><img src='http://ww2.valdosta.edu/~mecarter/Spongebob%20Reading.png' height='50px' widht='50px' ></div><br>
<div id="three"><img src='http://www.cliffdweller.com/blogPhotos/wrappingpaperbase/Spongebob%20Waving.png' height='50px' widht='50px' ></div><br><br>
<div id="thumb"><img src='http://img.widgetbox.com/thumbs/302/8fb0669c-72ee-454d-a08f-9700b8a5270a.png?4' height='200px' widht='200px' ></div>
jQuery
$("#one").click(function() {
$("#thumb").html("<img src='http://img.widgetbox.com/thumbs/302/8fb0669c-72ee-454d-a08f-9700b8a5270a.png?4' height='200px' widht='200px' >");
});
$("#two").click(function() {
$("#thumb").html("<img src='http://ww2.valdosta.edu/~mecarter/Spongebob%20Reading.png' height='200px' widht='200px' >");
});
$("#three").click(function() {
$("#thumb").html("<img src='http://www.cliffdweller.com/blogPhotos/wrappingpaperbase/Spongebob%20Waving.png' height='200px' widht='200px' >");
});
I start the page with the:
$selectedMenu = $_GET['selectedMenu'];
Then I have next and previous functions
<?php if ($prev) { ?>
<a href='?AID=<?=$prev?>&selectedMenu=$selectedMenu' style='background-image:url(/images/navDivider.png); background-position:right center; background-repeat: no-repeat; padding-bottom:4px; padding-top:4px;'>back </a>
<?php } else { ?>
<a href='gallery.php?CID=<?=$CID?>&SCID=<?=$SCID?>&selectedMenu=$selectedMenu' style='background-image:url(/images/navDivider.png); background-position:right center; background-repeat: no-repeat; padding-bottom:4px; padding-top:4px;'>back </a>
<?php } ?>
<?php if ($next){ ?>
<a href='?AID=<?=$next?>&selectedMenu=$selectedMenu'> next</a>
<?php } ?>
There is a query that pulls the AID, CID, and SCID
But what happens is that the $selectedMenu won't stay after the fist page even though I am passing it in the url. Any clues why it's dropping out?
Try using a query string management class. For example: https://github.com/kenaniah/insight/blob/master/classes/querystring.php
Example usage:
<?php
$qs = new QueryString;
$qs->CID = $CID;
print "<a href='blah.php".$qs."'>Link</a>";
?>
Try this:
<?php if ($prev) { ?>
back
<?php } else { ?>
back
<?php } ?>
<?php if ($next) { ?>
next
<?php } ?>
It was probably because you had a PHP variable in there without a surrounding PHP start and end tag. Also gave you proper echo statements.
Edit: Damn, realized you already got the answer.