How can i fix X-cart product page ? Product page is blank - x-cart

I have x-cart site which is running from 4 years and suddenly product page is not working. we have not done any changes.
X-Cart DB Version: 4.1.9 GOLD
product page url : https://www.test.com/product.php?productid=40&cat=0&page=1&featured
I can see bellow error in log file "x-errors_php-190521.php"
PHP Fatal error:
Call to undefined function func_get_categories_list() in public_html/include/common.php on line 76
if (
!isset($cat)
|| $config['Appearance']['root_categories'] == 'Y'
) {
$categories = func_get_categories_list(0, false);
} else {
Line No 76: =>>> $categories = func_get_categories_list($cat, false);
}
so help us to solve this issue

1) Try to add the
x_load('category');
in the include/common.php right after the
case 'C':
line
2) Try to compare your product.php with the default one and localize the problem.
3) Try to compare your include/common.php with the default one and localize the problem.
4) Try to compare your include/categories.php with the default one and localize the problem.
5) Try to move x_load('category'); before the code switch ($current_area) {
6) Try to add the code include_once $xcart_dir . '/include/func/func.category.php'; before the code switch ($current_area) {
Key notes:
include/common.php was added in X-Cart 4.4.0
The func_get_categories_list function is defined in
include/categories.php file in X-Cart 4.1.9
The func_get_categories_list function is defined in
include/func/func.category.php file in X-Cart 4.4.0
It will be helpful to define the exact version of your files for that compare
files like include/func/func.core.php cart.php include/func/func.category.php include/func/func.order.php with the default ones.

Related

How to add form alter hook in drupal 8

I am very much new to drupal 8, I am trying to alter a form under custom content type "Question". The form has an id "node-question-form".
I have setup a module and trying to add hook_FORM_ID_alter() but its never getting called. Even the simplest hook is not working. eg:
function constellator_form_alter(&$form, &$form_state, $form_id){
echo "alter the form"; exit;
}
where 'constellator' is the module name.
I have been stuck with since morning and nothing is working for me, Any help will be greatly appriciated.
Cheers
hook_form_alter() and hook_FORM_ID_alter() are called while a form is being created and before displaying it on the screen.
These functions are written in the .module file.
Always clear the cache after writing any hook function. This makes Drupal understand that such a function has been declared.
Use drush cr if using drush version 8 else click on Manage->Drupal 8 logo->Flush all Caches to clear the caches.
Now you can check if the function is being called or not.
The best way to check that is to install the Devel module, enable it. Along with Devel, Kint is installed. Enable Kint too from the Admin UI.
After doing that,you can check whether the hook is being called or not in the following way:
function constellator_form_alter(&$form, &$form_state, $form_id){
kint($form);
}
This will print all the form variables for all forms in the page.
If you want to target a particular form in the page, for eg. you form, node-question-form, type:
function node_question_form_form_alter(&$form, &$form_state, $form_id){
kint($form);
}
Using echo, the way you did, you can confirm whether the function is being called or not, without any hassle, by viewing the Source Code for the page and then searching for the text that you have echoed, using some search option of browser, like, Ctrl+f in case of Google Chrome.
If you want to change sorting options and/or direction (ASC / DESC), you can use this example (tested with Drupal 9).
Here I force the sorting direction according to the "sort by option" set by the user in an exposed filter. (if the user want to sort by relevance, we set the order to ASC, if the user want to sort by date, we set the order to DESC to have the latest content first).
/**
* Force sorting direction for search by date
*
*/
function MYTHEME_form_alter(&$form, &$form_state, $form_id)
{
if (!$form_id == 'views_exposed_form"' || !$form['#id'] == 'views-exposed-form-search-custom-page-1') {
return;
}
$user_input = $form_state->getUserInput();
if (empty($user_input['sort_by'])) {
return;
}
if ($user_input['sort_by'] == 'relevance') {
$user_input['sort_order'] = 'ASC';
} elseif ($user_input['sort_by'] == 'created') {
$user_input['sort_order'] = 'DESC';
}
$form_state->setUserInput($user_input);
}
Note that "views-exposed-form-search-custom-page-1" is the id of my form,
"relevance" and "created" are the sort field identifier set in drupal admin.
function hook_form_alter(&$form, \Drupal\Core\Form\FormStateInterface &$form_state, $form_id) {
echo 'inside form alter';
}

Direct link to language in OpenCart

I have a website(built with OpenCart) with multiple languages, e.g. English, German, French.
Users can change language using default functionality of the OpenCart - clicking on language icons on top.
Is it possible to send users automaticaly (so they don't have to click on the flag) from :
Germany to German version of the website
France to French version of the website
(English language is default)
Is there an URL I can use for these languages if the default page is for example http://mystore.com ?
(I noticed that when I click on the language icon the URL is not changing - it's the same for all languages)
Nowadays opencart doesn't support this function, but in the past , older versions of Opencart did have this function.
If you want to include this function in your website you will have to do the following:
Edit this file:
catalog/controller/module/language.php
find this:
class ControllerModuleLanguage extends Controller {
protected function index() {
if (isset($this->request->post['language_code'])) {
before the "if", you will have to include the following :
if (isset($this->request->get['lang'])) {
$this->session->data['language'] = $this->request->get['lang'];
if (isset($_SERVER['HTTP_REFERER']) && (strpos($_SERVER['HTTP_REFERER'], $this->config->get('config_url')) !== false) ) {
$this->redirect($_SERVER['HTTP_REFERER']);
} else {
$this->redirect($this->url->link('common/home'));
}
} else {
The source
An example of website with this code:
http://incomingtospain.com/madrid&lang=de
http://incomingtospain.com/madrid&lang=ru
This website has 8 idioms and you can access by different url, with this variable "lang" &lang=es &lang=en ... &lang=de &lang=ru
I think language is set in session variable
For the functionality you mentioned will be achive in following way:
Use the HTML5 geolocation to detect the location of user
Research in opencart to set the language function
after all done place your code using VQMOD if you want to do it in proper way
or you can also edit your core opencart files( Not recommended)
if the browser doesn't support geolocation or they refuse to share their location just load the default language.
With OpenCart 2.0, you must work on the file index.php (in your website root) and place this code :
if (isset($request->get['lang']) && array_key_exists($request->get['lang'], $languages)) {
$session->data['language'] = $request->get['lang'];
}
between line 155 and line 157
Line 153 to 154 :
foreach ($query->rows as $result) {
$languages[$result['code']] = $result;
}
(you add here the new code)
Line 157 :
if (isset($session->data['language']) && array_key_exists($session->data['language'], $languages)) {
Line 158 :
$code = $session->data['language'];

Facebook PHP SDK fatal error occures Facebook:: throwAPIException

try {
$return = $facebook->api("/" . $userFromDB["username"] . "/feed",
"post", array(
message => "",
picture => "http://blabla.net/blabla1/img/autopost/" . $blabla2 . ".png",
link => "http://apps.facebook.com/blabla1/?var2=" . $encryptedUserIds[$userFromDB["id"]], //$appPageURL
caption => "Tikla, begen.",
description => $var3,
access_token => $auth["auth_code"],
));
$usersPosted++;
} catch (FacebookApiException $e) {
$userProcessError++;
write_log("blabla");
}
Hello, this is the part of the code where i send posts to users' wall. If there is no exception, the code works flawlessly. Whenever an exception occures, I get this annoying fatal error.
I have tried many things to correct but the script is the same where I make calls to facebook api in other parts of my code.
I searched google and stackoverflow. Noone seems to have this error. Am i the only one? Thanks in advance.
This is the error:
Fatal error: Call to undefined method Facebook::throwAPIException() in facebook-php-sdk/src/base_facebook.php on line 870
Facebook sdk version i use: 3.2
Php version: 5.3
EDIT: this is how i get access_token for user. I store it into db:
if(isset($code) && $state==$authState){
$accessTokenInformation=file_get_contents($accessTokenURL . $code);
$tmpResult=explode("&", $accessTokenInformation);
if(sizeof($tmpResult)==2){
$tmpAT=explode("=", $tmpResult[0]);
$tmpExp=explode("=", $tmpResult[1]);
if(sizeof($tmpAT)==2 && sizeof($tmpExp)==2){
$tmpDBUserAuth=check_db_for_authcode_for_user(...);
if(empty($tmpDBUserAuth)){
insert_authcode_indb(...);
write_log(...);
}else{
update_authcode_indb(...)
write_log(...);
}
}else{
write_log(...);
echo(' top.location.href="'. $OAuthURL .'"; ');
}
}else{
write_log(...);
echo(' top.location.href="'. $OAuthURL .'"; ');
}
}
EDIT on 2012/11/06: Problem still persists. Please help.
Please check you FB API secrete keys are proper set or not ... I also faced this problem , but i have corrected secrete keys after that it was working perfect.
Try to use the following script
http://www.9lessons.info/2011/09/update-login-with-facebook-and-twitter.html
Fatal error: Call to undefined method Facebook::throwAPIException() in facebook-php-sdk/src/base_facebook.php on line 870
That error message does not make sense.
If I go to line 870 in that file in my IDE, and follow the method name to its declaration, it’s in the same file on line 1237 (all for current version 3.2.0).
So there is no plausible reason for a undefined method error there.
Could you please check if the SDK files got uploaded correctly to your server, or just re-download and re-upload them, to make sure its not a problem with mangled/truncated file contents?

Why is php_template_preprocess_page function not called in Drupal 6x?

From another forum I found the following example:
"I was looking for a way to pull node data via ajax and came up with the following solution for Drupal 6. After implementing the changes below, if you add ajax=1 in the URL (e.g. mysite.com/node/1?ajax=1), you'll get just the content and no page layout.
in the template.php file for your theme:
function phptemplate_preprocess_page(&$vars) {
if ( isset($_GET['ajax']) && $_GET['ajax'] == 1 ) {
$vars['template_file'] = 'page-ajax';
}
}
then create page-ajax.tpl.php in your theme directory with this content:
<?php print $content; ?>
"
This seems like the logical way to do it and I did this, but the phptemplate_preprocess_page function is never called ... any suggestions?
I figured it out for myself from a Drupal Support Theme Development page:
"Maybe this helps
leahcim.2707 - May 29, 2008 - 05:40
I was trying to get the same thing done and for me this works, but I'm not sure if it is the correct way as I'm still new to Drupal:
in "template.php" I added the following function:
function phptemplate_preprocess_page(&$vars)
{
$css = $vars['css'];
unset($css['all']['module']['modules/system/system.css']);
unset($css['all']['module']['modules/system/defaults.css']);
$vars['styles'] = drupal_get_css($css);
}
I think after adding the function you need to go to /admin/build/themes so that Drupal recognises the function."
The part in bold is what did the trick ... you have to re-save the configuration so it recognizes that you've added a new function to the template.

getElementsByTagName setAttribute and regex javascript

i want to put rel=lightbox to some links that mediabox support using javascript.
i try this and wonder why it's not working?
test: http://jsbin.com/opica
please help edit this: http://jsbin.com/opica/edit
<script type="text/javascript">
var x=xmlDoc.getElementsByTagName("a");
var regexku=/^.+(((twit)|(tweet)|(com/video.+)|(flickr.com.+)|(tube.com.+))|((gif)|(jpe?g)|(png)|(flv)|(swf)|(mp3)|(mp4))$)/;
for(i=0;i<x.length;i++)
{
a=x[i].getAttribute('href');
if (a.match(regexku) != null)
{
x.item(i).setAttribute("rel","lightbox");
}
}
</script>
So if you open the Error Console (Tools -> Error Console in Firefox), you'll see two errors on your page:
Error: xmlDoc is not defined
Source File: http://jsbin.com/opica
Line: 35
Error: invalid regular expression flag v
Source File: http://jsbin.com/opica
Line: 21, Column: 38
Source Code:
var regexku=/^.+(((twit)|(tweet)|(com/video.+)|(flickr.com.+)|(tube.com.+))|((gif)|(jpe?g)|(png)|(flv)|(swf)|(mp3)|(mp4))$)/;
The later is fixed by escaping the slash as Bart suggested (com\/video).
The former says there's no such thing as xmlDoc. You probably meant the page's document, in which case you should replace it with document.
Next the whole thing probably won't work because you should run the script after the page is finished loading. In jQuery it's $(document).ready(function() { /* do your work here */ }), google how to do it using the whatever framework you're using (mootools-yui?).
After that as you can see, the rel attribute is set on the links: http://jsbin.com/elaca/edit. The fact that the whatever library you're using still doesn't work means you're using it wrong. You didn't even link to the page you've downloaded the library from so that someone could look up the documentation for you...
Try escaping the / between com and video.