I just want to know if I can create Product block in local code pool (i.e. \app\code\local\Mage\Catalog\Block\Product.php) without making my custom module just place this single file?
If so, will this local code pool block call or the core one call? If it would be the local one, please let me know why.
If you copy a code/core file to the code/local repository, the core file will be overwritten by the local file.
This is because of the include path order to load system files specified in app/Mage.php:
$paths = array();
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'local';
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'community';
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'core';
$paths[] = BP . DS . 'lib';
So in your case the system will search for the Product.php in following order:
app/code/local/Mage/Catalog/Block/Product.php
app/code/community/Mage/Catalog/Block/Product.php
app/code/core/Mage/Catalog/Block/Product.php
lib/Mage/Catalog/Block/Product.php
If the system cannot find any of these files, it will throw an error.
Related
I want to modify the current template params via database outside joomla framework. I managed to set the 'preset' param, but I can't write it back to the database. Here is my code.
Thanks a lot
// Initialize The Joomla Framework
// -----------------------------------------------------------------------------------
define('_JEXEC', 1);
// this is relative to the current script, so change this according to your environment
define('JPATH_BASE', '/home/kristof/public_html/joomla1');
define('DS', DIRECTORY_SEPARATOR);
// Require Joomla libraries
require_once(JPATH_BASE . DS . 'includes' . DS . 'defines.php');
require_once(JPATH_BASE . DS . 'includes' . DS . 'framework.php');
require_once(JPATH_CONFIGURATION . DS . 'configuration.php');
require_once(JPATH_LIBRARIES . DS . 'joomla' . DS . 'database' . DS . 'database.php');
require_once(JPATH_LIBRARIES . DS . 'import.php');
// -----------------------------------------------------------------------------------
$app = JFactory::getApplication('site');
$template = $app->getTemplate(true);
$param=$template->params->set('preset','preset3');
$template = JFactory::getApplication('site')->getTemplate();
$db = JFactory::getDBO();
$sql = "select params from #__template_styles where template = ".$db->quote($template);
$db->setQuery($sql);
$params = json_decode($db->loadResult());
$params->PARAM_NAME= PARAM_VALUE;
$sql = "update #__template_styles set params = ".$db->quote(json_encode($params))." where template = ".$db->quote($template);
$db->setQuery($sql);
return $db->query();
i am new on wordpress and i am trying to merge a website with wordpress as a theme which contains its own php files and folders " forms, includes, ajax and others .. "
i am using this to define and call a path on my files
defined('SITE_ROOT') ? null : define('SITE_ROOT', DS . 'home' .DS . 'sitename' . DS . 'public_html');
when i tried to do this in wordpress , it doesnt work , so i typed the full path like this
defined('SITE_ROOT') ? null : define('SITE_ROOT', DS . 'home' .DS . 'sitename' . DS . 'public_html' . DS . 'wordpress' . DS . 'wp-content' . DS . 'themes' . DS . 'citation');
it works locally! .. i tried to upload it online and i changed the path to
defined('SITE_ROOT') ? null : define('SITE_ROOT', 'c:' .DS . 'wamp' . DS . 'www' . DS . 'wordpress' . DS . 'wp-content' . DS . 'themes' . DS . 'citation');
but it doesnt work.
after searching i found an absolute path for wordpress folder , then i tried it locally and it works!
defined('SITE_ROOT') ? null : define('SITE_ROOT', ABSPATH . DS . 'wp-content' . DS . 'themes' . DS . 'citation');
i tried it online but it doesnt work again ..
any one can help ?
You may use this syntax:
defined("SITE_ROOT") || define("SITE_ROOT", "provide url here");
But this is not the solution, just a nice shortcut for defining a constant, anyways, you don't need to do this, WorrdPress has TEMPLATEPATH, instead and also WordPress provided so any helper functions for this kind of things and one of those:
// Prints http://www.example.com/home/wp/wp-content/themes/yourThrme
echo get_bloginfo('template_url');
Or use
// prints http://www.example.com/home/wp/wp-content/themes/yourThrme
bloginfo('template_url');
Also, worth checking these available functions. Check WordPress Integration with other Website.
I'm trying to install TheStudio application which was apparently written using Zend Framework. My test server is running Ubuntu 12.04 and my application directory is stored in /home
My error log is stating
PHP Fatal error: require_once(): Failed opening required 'usr/share/php/libzend-frameworkphp/Zend/Loader/Autoloader.php'
(include_path='.:../library:../application/db:../application/models:../application/utils:../application/views/helpers:../application') in /home/application/config/config.php on line 22
Line 22 of config.php states:
require_once '/usr/share/php/libzend-framework-php/Zend/Loader/Autoloader.php';
The include path is as follows:
define('PS', PATH_SEPARATOR);
define('DS', DIRECTORY_SEPARATOR);
define('ROOT_DIR', dirname('home'));
// Modify include path
$paths = '.' . PS . '..' . DS . 'library'
. PS . '..' . DS . 'application' . DS . 'db'
. PS . '..' . DS . 'application' . DS . 'models'
. PS . '..' . DS . 'application' . DS . 'utils'
. PS . '..' . DS . 'application' . DS . 'views' . DS . 'helpers'
. PS . '..' . DS . 'application';
ini_set("include_path", $paths);
How should I modify the path statement to target the files located in /home directory? Are there other adjustments that should be made in order to resolve the above error?
/usr/share/php/libzend-frameworkphp is the default installation path for the Zend Framework Ubuntu package, so it seems this application is assuming that will be there. sudo apt-get install zend-framework should solve that problem.
I would say it's bad practice to include the full path on a require_once call, and there are way too many include paths being defined on your third code example (which I assume is from the app?).
I have created a rule in Jomsocial to award points for member who invites non users.. But now the problem is that...The points are awarded even
when the member enters "invite friends" page
points awarded when member sent email to a user(never checks whether user is a member in network or not)
How can I restrict this?
I need to award points only when the email is sent to a "non-user" or when the non-user clicks the link in the email body.
Currently this is used in components/com_community/libraries/mailq.php inside the function:
public function send( $total = 100 )
{
$mailqModel = CFactory::getModel( 'mailq' );
$userModel = CFactory::getModel( 'user' );
$mails = $mailqModel->get( $total, true );
$jconfig = JFactory::getConfig();
$mailer = JFactory::getMailer();
$config = CFactory::getConfig();
$senderEmail = $jconfig->getValue('mailfrom');
$senderName = $jconfig->getValue('fromname');
The code below is used to award points. I think some more conditions need to be added to make it validated:
if($senderName)
{
$JomSocialCheck = JPATH_BASE . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'userpoints.php';
if ( file_exists($JomSocialCheck)) {
include_once( JPATH_BASE . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'userpoints.php');
CuserPoints::assignPoint('com_user.add.friend');
}
}
My grandpa used to say: "when you're shouting - I hear you, when you're talking - I'm listening..." ;)
One of the two problems, I believe you can solve by modifying your code as follows:
if($senderName)
{
$JomSocialCheck = JPATH_BASE . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'userpoints.php';
if ( file_exists($JomSocialCheck)) {
include_once( JPATH_BASE . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'userpoints.php');
$user =& JFactory::getUser();
if($user->id) {
// he's already a user - do nothing
}
else {
CuserPoints::assignPoint('com_user.add.friend');
}
}
}
I'm just trying to build my first app on PHP Fog but there's a piece of code that doesn't run properly - works fine on localhost and other regular hosts though.
I use a modified version of TinyMVC, this is the code responsible for setting up autoloading:
/* Set include_path for spl_autoload */
set_include_path(get_include_path()
. PATH_SEPARATOR . FRAMEWORK_BASEDIR . 'core' . DS
. PATH_SEPARATOR . FRAMEWORK_BASEDIR . 'libraries' . DS
. PATH_SEPARATOR . FRAMEWORK_APPLICATION . DS . 'controllers' . DS
. PATH_SEPARATOR . FRAMEWORK_APPLICATION . DS . 'models' . DS
);
/* File extensions to include */
spl_autoload_extensions('.php,.inc');
/* Setup __autoload */
$spl_funcs = spl_autoload_functions();
if($spl_funcs === false)
spl_autoload_register();
elseif(!in_array('spl_autoload',$spl_funcs))
spl_autoload_register('spl_autoload');
Basically, it fails at the first class it should load, which is located in "FRAMEWORK_BASEDIR . 'core' . DS". The class filename is "framework_controller.php" and class name is "Framework_Controller" (tried lowercase as well). If I include the class manually it works but fails with autoload.
Here's the error message that I get:
Fatal error: spl_autoload(): Class Framework_Controller could not be loaded in /var/fog/apps/app7396/claudiu.phpfogapp.com/application/controllers/home.php on line 12
Any ideas as to what could the problem be?
I managed to sort it out:
function framework_autoload($className, $extList='.inc,.php') {
$autoload_paths = array (
FRAMEWORK_BASEDIR . 'core' . DS,
FRAMEWORK_BASEDIR . 'libraries' . DS,
FRAMEWORK_APPLICATION . DS . 'controllers' . DS,
FRAMEWORK_APPLICATION . DS . 'models' . DS
);
$ext = explode(',',$extList);
foreach($ext as $x) {
foreach ($autoload_paths as $v) {
$fname = $v . strtolower($className).$x;
if(#file_exists($fname)) {
require_once($fname);
return true;
}
}
}
return false;
}
spl_autoload_register('framework_autoload');
Thanks to another question here on StackOverflow: spl_autoload problem