I'm writing vqmod opencart modification and got one problem. There's a basic code:
<operation>
<search position="after"><![CDATA[<?php echo $description; ?></div></div>]]></search>
<add>
<![CDATA[<div class="content"><h2>Testimonials</h2><div class="box-testimonial"><?php echo $description_new; ?></div></div>]]>
</add>
</operation>
So What I want to do is to make some kind of conditional to display the code from only when $description_new is not empty. What will be the syntax in this vqmode code?
Thanks in advance,
Arek
ok i figured out. It seems like it's usual php syntax inside CDATA
<![CDATA[<?php if (isset($this->data['description_new'])) { echo '<div class="content"><h2>Testimonials</h2><div class="box-testimonial">' . $description_new . '</div></div>'; } else { echo ' '; }?>]]>
vQmod simply allows you to insert code just like you would normally into a file, but without actually touching the file contents. So yes using an if statement just like you have is fine. Also, one thing I would point out is you should use as little content as you can for the search portion, that's unique. So for your above code
echo $description;
should be enough to match. It also makes it less likely to break should you use other mods
Related
I have a script for vqmod opencart made in this way:
<modification>
<file name="catalog/view/theme/*/template/common/header.tpl">
<operation>
<search position="replace"><![CDATA[<title><?php echo $title; ?></title>]]></search>
<add><![CDATA[<title><?php
$separator=" | ";
$store_name=$this->config->get('config_name');
if(trim($store_name)!=trim($title))
echo $title.$separator.$store_name;
else
echo $title;
?></title>]]></add>
</operation>
</file>
</modification>
I would like to show in every page not the website name (config_name), but the homepage title that is different and more complete. Moreover it is different for every language of my site. Can you help me in some way?
Thank you
thanks for the answer. I would like to add at the end of the meta title of every page (all of them, products, categories, informations etc) a string of words of my choice. For example if the title is " #productname, #category, #brand " , I want it to be " #productname, #category, #brand - #mysitename #mysitedescription". The problem is that #mysitename #mysitedescription have to be different for every language automatically.
I hope to have well explained the problem
I've been running open cart on my server for a client, but it's acting rather strange. when we try to access the images to attach to a product, we get this this login image inside the 'image manager' pop up window. and the buttons to Rename, new folder and so on change color.
I can't seem to find anything on google, have you seen this before or have any idea if i got hacked or something happened?
I'm running version 1.5.6.3
After i click to add ANY image it adds that login segment. and I can try to log in, but I haven't tried.
This is the way it pops up first, THEN it turns into the image above.
This is the correct way it should stay.
Same problem here. It used to work properly for more than a year and it stopped working days ago, without changes or updates to my website. What hosting company are you on? I'm on Bluehost, trying to understand if they changed something...
EDIT: ok I've found a solution here: http://forum.opencart.com/viewtopic.php?f=161&t=93875&start=40
I've created a vqmod file called fix-image-manager.xml and put it in /vqmod/xml, as suggested in that post. This is the content of the file:
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<id>IMAGE MANAGER FIX</id>
<version>1.5.6.1</version>
<vqmver required="true">2.5.0</vqmver>
<author>OpenCart</author>
<file name="admin/view/template/common/filemanager.tpl">
<operation>
<search position="replace"><![CDATA[&token=<?php echo $token; ?>&image=' + encodeURIComponent('data/' + $(element).find('input[name=\'image\']').attr('value'))]]></search>
<add><![CDATA[&image=' + encodeURIComponent('data/' + $(element).find('input[name=\'image\']').attr('value'))+'&token=<?php echo $token; ?>']]></add>
</operation>
</file>
<file name="admin/view/template/catalog/*">
<operation>
<search position="replace"><![CDATA[&token=<?php echo $token; ?>&image=' + encodeURIComponent($('#' + field).attr('value'))]]></search>
<add><![CDATA[&image=' + encodeURIComponent($('#' + field).attr('value')) + '&token=<?php echo $token; ?>']]></add>
</operation>
</file>
</modification>
If you don't use vqmod, you should just edit admin/view/template/common/filemanager.tpl and change this line:
'index.php?route=common/filemanager/image&token=<?php echo $token; ?>&image=' + encodeURIComponent('data/' + $(element).find('input[name=\'image\']').attr('value')),
to this:
'index.php?route=common/filemanager/image&image=' + encodeURIComponent('data/' + $(element).find('input[name=\'image\']').attr('value'))+'&token=<?php echo $token; ?>',
and do the same thing in all the files in admin/view/template/catalog/ where the same line is present.
Apparently the &token should be the last parameter. I still can't get why it has worked properly so far and suddenly it stopped working.
I would suggest checking your tokens that are in the address bar of the iframe for the image adding screen, when the tokens are incorrect this problem happens. It is because the system looks at you as a non logged in user.
Go to the file manager page directly from your browser when you logged in to the backend to see if it exists and navigates to correctly.
index.php?route=common/filemanager
Remember to leave the token part in your address bar and just change the above
If it navigates to this page correctly then you will have to find the link to the image iframe and compare the tokens to the ones you are logged in with (see browser address). If it doesn't navigate to this page correctly then you will have to look at the coding for that specific page.
If I click on a product from my product overview on the left side, the shop does not load with the list.phtml. As soon as I swap view to grid or list, it swaps to the list.phtml file and everything is fine. But as I said, if I click on the products on the sidebar, it doesnt work (it's not even affected by list.phtml at all). I removed all the code inside it and it still showed (a bit different, that's why I want to change it) the products, but as soon as I swapped mode, everything disappeared -- as it should. Do you know where I can change that?
Thank you.
It should use list.phtml file. In that file it is defined for both list mode and grid mode.
<?php echo $this->getToolbarHtml() ?>
<?php // List mode ?>
<?php if($this->getMode()!='grid'): ?>
<?php $_iterator = 0; ?>
And
<?php else: ?>
<?php // Grid Mode ?>
<?php $_collectionSize = $_productCollection->count() ?>
You can see something like above code in your list.phtml file,one is for list mode and another for grid mode. This is the default case unless you haven't changed the layout or template code.
If you want to know the file location than you can always enable template path hint. If you don't know how to do that you can follow this.
After knowing from which file it is rendering you can fix it.
Hope this will help.
Does anybody know how can I remove the meta tag description without changing Joomla core. I found that addingup $this->setDescription(null); in my template it would work but this just leave the tag empty. I'd like to take this off at all.
I have spent the whole afternoon researching but it seems like changing core is the only option, however I'm not comfortable with this option since a future upgrade may overwrite my changes.
Thanks in advance!
in templates/mytemplate/ component.php /index.php remove the following :
<jdoc:include type="head" />
this will remove all elements
however it will also remove all js & css files which is not cool! so what i would do is this:
to access all the head elements as an array: $document = $this->getHeadData();
to access path ref: $baseURL=JURI::base(true);
to grab all scripts (inc all loaded with addScript()method) :
foreach ($document[scripts] as $key=>$value){
if (stristr($key,$baseURL)==NULL){$url= $baseURL."/".$key ;}else{$url=$key;}
$scripts .= "<script type=".$value." src=".$url."></script>";
};
to grab all stylesheets (inc all loaded with addStyleSheet()method):
foreach ($document[styleSheets] as $key=>$value){
if (stristr($key,$baseURL)==NULL){$url= $baseURL."/".$key ;}else{$url=$key;}
$style .= "<link rel='stylesheet' type=".$value[mime]." href=".$url." />";
};
to grab all internal script elements (e.g. added with addScriptDeclaration or JFactory::getEditor) use this with the script method:
foreach ($document[script] as $key=>$value){
$scripts .= "<script type=".$key." >".$value."</script>";
}
to grab all custom scripts (e.g. editor initialization params) :
foreach ($document[custom] as $value){
$custom .= $value;
}
finally echo the statements in the <head> :
<?
echo $style;
Echo $scripts;
echo $custom;
?>
Also the other way (without hacking the component.php) is to create a new tmpl file in the template folder i.e:
[path to install]/template/mytemplate/
in that folder there will be Index.php and component.php
you can create another one e.g. blank.php
and specify the headers you want here
with <jdoc:include type="component" />
call it with ?tmpl=blank
This can be done with a plugin. There isn't one that removes the tag entirely that I know of, however these is a plugin that removes the generator tag completely. You could easily modify this plugin to do the same for the description tag instead.
http://extensions.joomla.org/extensions/site-management/seo-a-metadata/12556
I'm making an automated script with PHP to check if my link exists at my partner website ( link exchange) .. besides making sure my link exists in the source code , I want to make sure he is not placing it in a HTML comment like <!-- http://www.mywebsite.com --> and cheating me ..
I tried to match it with REGEXP , but have failed
Use the DOM and XPath, it ignores comments:
$doc = new DOMDocument();
$doc->loadHTML($htmlstring);
$xpath = new DOMXPath($doc);
$result = $xpath->query('//a[contains(#href, "mywebsite.com")]');
if (!$result->length) echo "You've been cheated\n";
And then if you still want to know if your website is being commented out
if (strpos($htmlstring, 'mywebsite.com') !== false && !$result->length)
echo "Your partner is hiding your link in a comment, sneaky bastard\n";
Sounds like a perfect use for an HTML parser like DOMDocument->loadHTML() and look for an anchor tag with your link. He could still remove it via javascript on the browser side, but that's a different issue.
If it's a cat and mouse game of "are you showing a link to my site" using a standard parser is your best bet. There are just too many ways for a regex to fail on html.