How to hide logo in product page in Open Cart? - php

I need to hide logo in product page. Logo is placed in header HTML.
So, I tried to add new variable $data['product_page_logo'] in header.php controller before loading template like as:
$data['product_page_logo'] = false;
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header.tpl')) {
return $this->load->view($this->config->get('config_template') . '/template/common/header.tpl', $data);
} else {
return $this->load->view('default/template/common/header.tpl', $data);
}
After in header.tpl I check this variable:
<? if(isset($data['product_page_logo']) && $data['product_page_logo'] == false) {
echo "Logo";
}?>
But it does not work, I get error undefined variable product_page_logo

You can use route, in catalog/controller/common/header.php find:
$class = '-' . $this->request->get['product_id'];
before or after it add:
$data['logo'] = '';
tested on opencart 2.3.0.2

Related

slug its not working in codeigniter

i want url slug like this
tkd/index.php/article/77/Kejurnas-2013
but when i click button like this
tkd/index.php/article/77/Kejurnas%202013
what wrong with my code. this is my view
<div class="post-buttons-wrap">
<div class="post-buttons">
<a href="<?php echo base_url('index.php/article/' . intval($dt->id) . '/' . e($dt->slug)) ; ?>" class="ui black label">
Read More
</a>
</div><!-- end .post-buttons -->
</div>
and this is my controller
public function index()
{
$this->data['berita'] = $this->mberita->get_berita();
$this->data['halaman'] = $this->mhalaman->get_profil();
dump('Page!');
// Fetch the page template
$this->data['page'] = $this->page_m->get_by(array('slug' => (string) $this->uri->segment(1)), TRUE);
count($this->data['page']) || show_404(current_url());
// Fetch the page data
$method = '_' . $this->data['page']->template;
if (method_exists($this, $method)) {
$this->$method();
}
else {
log_message('error', 'Could not load template ' . $method .' in file ' . __FILE__ . ' at line ' . __LINE__);
show_error('Could not load template ' . $method);
}
$this->data['contents'] = $this->data['page']->template;
$this->load->view('template/wrapper_mahasiswa', $this->data);
}
please help me what to do. thank you.
You have to use the helper "URL" and use the functions "url_title()" and "convert_accented_characters()" if you need to convert some special characters.
http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html for more info
Example:
In your controller code, you will capture your form inputs. then you have to create the slug with a line like this:
$event['slug'] = url_title(convert_accented_characters($event['eventName']),'-',TRUE);
This line will return you a slug separated by "-", setting all the words to lowercase and deleting all special characters too.
try this- use rawurlencode while working with strings in url-
<a href="<?php echo base_url('index.php/article/' . intval($dt->id) . rawurldecode('/') . e($dt->slug)) ; ?>" class="ui black label">
Read More
</a>

php: Remove/show specific link from menu based on page displaying

Newb here working on refining a function to deliver a better user experience.
My goal is that if we are not on the index page (home) of the site, i wish to include a link to return to the home page. But if we are on the index page (Home), i don't wish to display the redundant link in the menu. Below is the function I've built, which you can see here 'school.max-o-matic.com'. at the bottom of the right navigation menu is a link that reads '< back' which should not show on the index page but should ideally show on all other pages.
I'd hoped the use of the exclamation point followed by an equal sign would do the trick but it did not.
<?php
function makeNav($navItem) {
//created variable - plops in what is called when function used on
//page calling the function itself - this is like the strPromp
$output = ''; //Variable of 0 length
foreach ($navItem as $pageLink => $displayedLink) {
if ($pageLink == THIS_PAGE) {
//url matches page - add active class
$output .='<li class="active">'
. '' . $displayedLink . ''
. '</li>' . PHP_EOL;
} //PHP_EOL is php line end for all systems
else {//don't add class
$output .='<li>'
. '' . $displayedLink . ''
. '</li>';
}
}
if ($pageLink != 'index.php') {//add back button to index page
$output .='<li>'
. '< Back'
. '</li>' . PHP_EOL;
} //PHP_EOL is php line end for all systems
$output .='<li>'
. 'contact'
. '</li>';
return $output;
}
?>
if($_SERVER['PHP_SELF'] != '/index.php'){ //process if file is not index file.
}
to exclude access to index file.
if (strpos($_SERVER['PHP_SELF'],'index.php') !== false) { //process if file contains text "index.php" in filename.
}
//to exclude access to any file with name containing "index.php" file
if (basename($_SERVER['SCRIPT_NAME']) != 'index.php'){
//run on all files that ARE NOT index files in any folders.
}
You could check this by using the $_SERVER global variable, which is an array of request information. The key 'SCRIPT_NAME' contains the path to the requested file. The check on this could be:
if (basename($_SERVER['SCRIPT_NAME']) != 'index.php') {

How to insert a php code from another php file?

Im creating a custom function for my wordpress website that will add a review section below the post content and i need to insert this function from another another file into a custom function that i added to my functions.php. I need to get this piece of code $buffy .= $this->get_review(); from a different file to work in this function:
function content_injector($content) {
global $wp_query;
$postid = $wp_query->post->ID;
if (is_single((get_post_meta($postid, 'top_ad', true) != 'off' ))) {
$top_ad = do_shortcode('[td_ad_box spot_name="Ad spot -- topad"]');
}
if (is_single((get_post_meta($postid, 'bottom_ad', true) != 'off' ))) {
$bottom_ad = do_shortcode('[td_ad_box spot_name="Ad spot -- topad"]');
}
if (is_single()) {
$review = //HOW DO I ADD THAT get_review CODE HERE?
$custom_share = '<div id="title-deel"><h4 class="block-title"><span>DEEL</span></h4></div>' . do_shortcode('[ssba]');
$facebook_comments = '<div id="title-reageer"><h4 class="block-title"><span>REAGEER</span></h4></div>' . '<div class="fb-comments" data-href="' . get_permalink() . '" data-colorscheme="light" data-numposts="5" data-mobile="false" data-width="700"></div>';
}
$content = $top_ad . $content . $bottom_ad . $custom_share . $facebook_comments;
return $content;
}
add_filter('the_content', 'content_injector');
As you can see i need to add the get_review function to $review, but i cant make it work on my own. How to make this work?
Use include to include the file before using any methods from that file.
include("file_with_functions.php");
OR
Create a class (with filename same as classname).
Include the file.
Create an instance of the class.
Access the method in the class through the object

Cannot modify header information - headers already sent in WordPress [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Headers already sent by PHP
When I go into wp-admin on www.newswars.org, I see the following error:
Warning: Cannot modify header information - headers already sent by (output started at /home/newswars/public_html/wp-content/themes/videoplus/functions.php:38) in /home/newswars/public_html/wp-includes/option.php on line 563
Warning: Cannot modify header information - headers already sent by (output started at /home/newswars/public_html/wp-content/themes/videoplus/functions.php:38) in /home/newswars/public_html/wp-includes/option.php on line 564
Can you please help?
EDIT: Ok its this that is causing me the problem.
$user_ej = wp_get_current_user();
if ($user_ej->roles[0] == 'contributor')
{ ?>
This is 36-38 lines. For some reason its getting all messed up. Still I'm not quite sure what the problem is. I tried removing ?> but that gave me a syntax error. I'm at a loss. It is definitely the problem area as it only comes up when someone logs in a 'contributor'.
<?php
// Translations can be filed in the /lang/ directory
load_theme_textdomain( 'themejunkie', TEMPLATEPATH . '/lang' );
require_once(TEMPLATEPATH . '/includes/sidebar-init.php');
require_once(TEMPLATEPATH . '/includes/custom-functions.php');
require_once(TEMPLATEPATH . '/includes/post-thumbnails.php');
require_once(TEMPLATEPATH . '/includes/theme-postmeta.php');
require_once(TEMPLATEPATH . '/includes/theme-options.php');
require_once(TEMPLATEPATH . '/includes/theme-widgets.php');
require_once(TEMPLATEPATH . '/functions/theme_functions.php');
require_once(TEMPLATEPATH . '/functions/admin_functions.php');
function wpr_snap($atts, $content = null) {
extract(shortcode_atts(array(
"snap" => 'http://s.wordpress.com/mshots/v1/',
"url" => 'http://www.catswhocode.com',
"alt" => 'My image',
"w" => '400', // width
"h" => '300' // height
), $atts));
$img = '<img src="' . $snap . '' . urlencode($url) . '?w=' . $w . '&h=' . $h . '" alt="' . $alt . '"/>';
return $img;
}
add_shortcode("snap", "wpr_snap");
$user_ej = wp_get_current_user();
if ($user_ej->roles[0] == 'contributor')
{ ?>
<style type="text/css">
#menu-dashboard, #toplevel_page_wpcf7, #menu-tools
{
display:none;
}
</style>
<?php }
add_filter( 'gettext', 'change_post_to_portfolio' );
add_filter( 'ngettext', 'change_post_to_portfolio' );
function change_post_to_portfolio( $translated ) {
$translated = str_ireplace( 'Posts', 'VIDEOS', $translated ); // ireplace is PHP5 only
return $translated;
}
// Uncomment this to test your localization, make sure to enter the right language code.
// function test_localization( $locale ) {
// return "nl_NL";
// }
// add_filter('locale','test_localization');
// Adds categories to pages
add_action('admin_init', 'reg_tax');
function reg_tax() {
register_taxonomy_for_object_type('category', 'page');
add_post_type_support('page', 'category');
}
add_action('admin_footer', 'my_admin_footer');
function my_admin_footer()
{
$uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : NULL ;
$message = NULL;
if ($uri AND strpos($uri,'edit.php'))
{
if (strpos($uri,'post_type=page'))
{
$message = '1.In the ‘Video Embed Code section,’ enter the video embed code. 2.Enter the title and text in the main panel below. 3.Choose which continent and category is most fitting for your video. 4.Press ‘Publish’';
}
else
{
$message = 'ALL VIDEOS';
}
}
elseif ($uri AND strpos($uri,'post-new.php'))
{
if (strpos($uri,'post_type=page'))
{
$message = 'Add pages here';
}
else
{
$message = '1.In the ‘Video Embed Code section,’ enter the video embed code. 2.Enter the title and text in the main panel below. 3.Choose which continent and category is most fitting for your video. 4.Press ‘Publish’';
}
}
elseif ($uri AND strpos($uri,'post.php'))
{
$message = 'THREE';
}
if ($message)
{
?><script>
jQuery(function($)
{
$('<div style="margin-bottom:15px; color:#FF0000;"></div>').text('<?php echo $message; ?>').insertAfter('#wpbody-content .wrap h2:eq(0)');
});
</script><?php
}
}
?>
add_shortcode("snap", "wpr_snap");
$user_ej = wp_get_current_user();
if ($user_ej->roles[0] == 'contributor')
{ ?>
<style type="text/css">
#menu-dashboard, #toplevel_page_wpcf7, #menu-tools
{
display:none;
}
</style>
<?php }
add_filter( 'gettext', 'change_post_to_portfolio' );
add_filter( 'ngettext', 'change_post_to_portfolio' );
isn't inside a function. So it's being called as soon as the file loads. This means all output is sent to the screen immediately This stuff should be inside a function which is then called at the right time (like the other bits).

Text problem in template machine

I have this code:
class template
{
public $template,$prefix,$replace;
function __construct($template, $prefix)
{
$this->prefix = $prefix;
$this->template = $template;
}
public function SetValue($name, $replace)
{
$this->replace["#".$name."#"] = $replace;
}
public function Tempclude($found)
{
$file = "styles/main/".$found[1].'.html';
if(!file_exists($file))
exit("the template '" . $found[1] . "' wasn't found.");
return file_get_contents($file);
}
public function finish($stream = "normal")
{
if($stream == "folder")
$code = file_get_contents("../styles/main/".$this->template.".html");
else
$code = file_get_contents("styles/main/".$this->template.".html");
$code = preg_replace_callback("#<pb:include=\"(.*)\">#iuU", array($this, 'Tempclude'), $code);
if(is_array($this->replace))
$code = str_replace(array_keys($this->replace), $this->replace, $code);
$code = str_replace("\r\n", "", $code);
$code = str_replace(" ", "", $code);
echo $code;
}
}
If I type in the Template some simple text, the page turns white with nothing inside.
What is the problem?
it is no the problem.
Try doing this:
$template = new template("index", "");
$template->SetValue("notice", "notice:");
$template->finish();
and index.html:
<pb:include="header">
hhh
#Slider#
<pb:include="footer">
its work.
if you change index.html to:
<pb:include="header">
<div id="hh">
hhh
</div>
#Slider#
it return a white list with somthing inside.
I have found the unquoted constant shows warning (depends on php configuration, WAMP does)
In the edited code that you have problem with errors, only quote the two constants in the begining it should work okay, test it like this:
$template = new template("index", "");
$template->SetValue("notice", "notice:");
$template->finish();
folder structure: styles/main must be provided. These files must be found inside main: index.html, footer.html, header.html must be privided
When everything okay, please try to delete any uneccessary comments or answers.
Thank you!

Categories