Can't access node-taxonomy.tpl.php through page-taxonomy-term.tpl in Drupal 6 - drupal-6

I've been trying to customize taxonomy page template in my Drupal 6 site.
What I did was
created page-taxonomy-term.tpl.php
created node-taxonomy.tpl.php
Entered following code in template.php:
function templateNAME_preprocess_node(&$vars) {
if (arg(0) == 'taxonomy') {
$suggestions = array(
'node-taxonomy'
);
$vars['template_files'] = array_merge($vars['template_files'], $suggestions);
}
My Taxonomy page is picking up page-taxonomy-term.tpl.php correctly but it just doesn't pick up node-taxonomy.tpl.php and I tried just almost everything.

below few tips and attempts to do:
if you are working on subtheme, copy node.tpl.php from parent theme to the folder under subtheme (mandatory in drupal 6 themes).
try to check if the node-taxonomy suggestions is correctly added in
object $node. var_dump($node) inside the main node.tpl.php and check
if is present.
last tips: check the permission of the file tpl, maybe is not readable from the web server.

Related

Navigating from Location to Workorder

I need to :
1. Create a single page location application
2. Display all the asset present in the selected location in a table
3. Provide a button from which user can navigate to WOTRACK to view all the workorder(s) created on selected location and its asset(s).
I am facing difficulty in the 3rd one. I have tried Launch in Context and it is working fine except am not able to pass sql query like 'location={location} and assetnum in ({asset.assetnum})'. I need to filter workorders with particular location and all its assets.
I tried to save all the assets in the location to a Non-persistant attribute and passing the values of the attribute in the Launch in context url, Its working as expected but to do so I have written a script on 'Initialize value' which is causing performance issues.
script goes like this:
from psdi.server import MXServer;
from psdi.mbo import MboConstants;
if app == "LOCATION1" :
if mbo.getString("LOCATION") is not None:
Locsite = mbo.getString("SITEID")
desc = mbo.getString("DESCRIPTION")
MaxuserSet = MXServer.getMXServer().getMboSet("MAXUSER", mbo.getUserInfo())
MaxuserSet.setWhere(" userid='"+user+"' ")
MaxuserSet.reset()
UserSite = MaxuserSet.getMbo(0).getString("DEFSITE")
if Locsite == UserSite:
AssetSet = mbo.getMboSet("ASSET")
AssetSet.setFlag(MboConstants.DISCARDABLE, True);
if not AssetSet.isEmpty():
AssetList = ""
AssetMbo = AssetSet.moveFirst()
while AssetMbo is not None:
AssetList = AssetList + str(AssetMbo.getString("ASSETNUM")) + "%2C"
AssetMbo = AssetSet.moveNext()
mbo.setValue("non-persitant",str(AssetList),11L)
and in the LIC url i have given : 'http://xx.x.x.xx/maximo/ui/?event=loadapp&value=wotrack&tabid=List&additionalevent=useqbe&additionaleventvalue=location={LOCATION}|assetnum={non-persistant}'
Is there any other feasible solution to the requirement?
Thanks in Advance
Launch In Context is better used for sending the user to an outside-of-Maximo application and passing along some data from inside-Maximo to provide context in that external app.
What you are doing sounds like a good place to use a workflow process with an Interaction node. The developer tells the Interaction node which app to take the user to and which Relationship to use to find the data the user should work with there.
Why don't you add a table control inside the table details (expanded table row) and show a list of the work orders there. From the WONUM in that table, you could have an app link to take them to WOTRACK, if they want more details about a particular work order. No customization (automation scripting) needed. No workflow needed. Nice and simple.

Prestashop Friendly URL's

I've been trying to create a second option of url rewrites to a product inside prestashop. In the standard Prestashop installation at the SEO & URL's section i've got the following products url build-up:
{category:/}{id}-{rewrite}-{ean13}.html
This creates the following products url:
https://www.example.com/{category-name}/{product-id}/{product-name}/{ean13}.html
What i would like to add is an option for various reasons to acces a products page through the following url build up:
ean/{ean13}.html
The result url would be something like the following example:
https://www.example.com/ean13/{ean13}.html
NOTE, ID is a standard required field of the url build up, this means that i can't use: "Just ajust the url build up" as an answer.
Is there a module, addon, or piece of code out there that would be able to generate these kind of structures?
I did find some "Remove ID's from pretty url's" modules but that doesn't give me the result i'm searching for. Only partially since it only removes the ID's.
It wouldn't be a problem if it's a redirect to the standard url build up as mentioned in the first {code} segment. I know i could write rewrite rules in my .htacces file but to do this for every product would be a lot of work so i was wondering if there is a more easy way of achieving this.
As always thanks in advance!
If you're fine with redirect to standard URL then the solution is quite easy with a module.
Create a module that uses hook moduleRoutes and configure a friendly URL to use module controller
Create a module front controller
Run a db query in your custom controller to check if a product with requested EAN exists
Redirect to product page if product exists, otherwise to 404 page or something
I assume you know how to write modules and controllers, so I won't write entire code just the relevant bits.
Hook moduleRoutes in module class.
In this hook you can configure a friendly URL for your custom controller.
public function hookModuleRoutes()
{
return [
'mymodulename-mycontrollername-root' => [
'rule' => 'ean13/{:ean13}.html',
'controller' => 'mycontrollername',
'keywords' => [
'ean13' => ['regexp' => '[0-9]+', 'param' => 'ean13']
],
'params' => [
'fc' => 'module',
'module' => 'mymodulename'
]
]
];
}
So visiting https://www.example.com/ean13/12345.html will run your module controller and a GET variable ean13 will have a value of 12345.
Then create mycontrollername module controller where you can use postProcess() method to check if EAN exists.
public function postProcess()
{
$query = new DbQuery();
$query->select('id_product')
->from('product_attribute', 'pa')
->where('pa.ean13 = ' . (int)Tools::getValue('ean13'))
$productId = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
if ($productId) {
Tools::redirect($this->context->link->getProductLink($productId));
}
Tools::redirect('pagenotfound');
}
In query we check in product_attribute table as product combinations can have their own EAN13 and you also want those EAN13's to redirect to product page.
The basics of this answer is most commonly used to replace core product search controller with a custom and SEO friendly one.

How to set a category to a Liferay Web Content in Java?

In Liferay 7, I have a Web Content, a vocabulary and a category.
How to set the category to the Web Content?
I wrote this code:
article = JournalArticleLocalServiceUtil.addArticle(...);
category = AssetCategoryLocalServiceUtil.addCategory(...);
AssetCategoryLocalServiceUtil.setAssetEntryAssetCategories(
article.getPrimaryKey(), new long[]{category.getPrimaryKey()});
At execution no error, but the category does not show up on the edit page of the created Web Content:
The category has been created successfully, but the Web Content does not get that category assigned.
What am I doing wrong?
I have also tried addAssetEntryAssetCategories, addAssetEntryAssetCategory, addAssetCategoryAssetEntry: same problem.
Try using any of these 2 functions to add category:
addAssetEntryAssetCategory(long entryId, long categoryId);
addAssetEntryAssetCategories(long entryId, long[] categoryIds);
In your code, you are using primary_key, however, as per documentation you should be using entry id and category id. So your function call should look like this:
AssetEntry entry = AssetEntryLocalServiceUtil.fetchEntry(JournalArticle.class.getName(), article.getResourcePrimKey());
AssetCategoryLocalServiceUtil.addAssetEntryAssetCategory(
entry.getEntryId(), category.getCategoryId());
Since 7.0, they removed the getEntryId method from JournalArticle you would need an additional call to fetch it. There is a update method which you may also consider that would do this in single call. I'm still using 6.2 and catching up 7 :).
Please note categories are designed for use by administrators, not regular users.
I am using liferay 7.1 dxp
In my case I have to update category of journal article or web content using program.
In order to achieve this I have to use assetEntryAssetCategoryRel class.
to access this and related class first I added dependency to my build.gradle file
compileOnly group: "com.liferay", name: "com.liferay.asset.entry.rel.api", version: "1.1.0"
List<AssetEntryAssetCategoryRel> assetEntryAssetCategoryRelsByAssetEntryId = AssetEntryAssetCategoryRelLocalServiceUtil.
getAssetEntryAssetCategoryRelsByAssetEntryId(assetEntry.getEntryId());
if(assetEntryAssetCategoryRelsByAssetEntryId!=null && !assetEntryAssetCategoryRelsByAssetEntryId.isEmpty()){
AssetEntryAssetCategoryRel assetEntryAssetCategoryRel = assetEntryAssetCategoryRelsByAssetEntryId.get(0);
assetEntryAssetCategoryRel.setAssetCategoryId(assetCategory.getCategoryId());
assetEntryAssetCategoryRel = AssetEntryAssetCategoryRelLocalServiceUtil.updateAssetEntryAssetCategoryRel(assetEntryAssetCategoryRel);
}
I had assetentry and assetcategory object
This works fine for me

How can I access the current user's roles in Orchard from a view page?

I am trying to get the current user's roles in Orchard 1.9.2 from a view.
I tried this snippet of code but it always returns 0 roles:
var roles = ((ContentItem)WorkContext.CurrentUser.ContentItem).As<UserRolesPart>().Roles;
source: https://www.cloudconstruct.com/blog/retrieving-role-information-in-your-orchard-view-templates
Any ideas?
Perhaps the using statement is missing?
Try the following code:
#using Orchard.ContentManagement
#{
var roles = WorkContext.CurrentUser.As<Orchard.Roles.Models.UserRolesPart>().Roles;
}
edit 1
It seems like the user is not authenticated. The line of code posted above creates the following calls:
Orchard.Environment.WorkContextImplementation.GetState("CurrentUser")
Orchard.Environment.WorkContextImplementation.FindResolverForState("CurrentUser")
enumerating through a list of IWorkContextStateProvider, in this list there should be the following implementation: Orchard.Security.CurrentUserWorkContext
Orchard.Security.CurrentUserWorkContext.Get("CurrentUser")
IAuthenticationService.GetAuthenticatedUser() -> which returns the user when authenticated
So it seems that any of these steps returns without the user. I suggest you create a breakpoint in Orchard.Environment.WorkContextImplementation.GetState() to find out where the issue is.

Load content by id using Drupal6 Rules module

Would like to add files to a Drupal6 user's account based upon certain conditions (basically just upon new account creation). I want to use the Rules module to accomplish this but the conditional items don't seem to cover this action. Probably if you select the "Execute Custom PHP code" it is possible, but this out of my programming league. Any ideas welcome.
mmmm ok maybe u will find creating a new module is something difficult but its very easy..lets do it
1- go to /sites/all/modules
2- create new folder called when_user_login (lets called our new module when_user_login)
3- create inside this folder when_user_login.info include the following code
name = when user login
description = this module do something when user login
core = 6.x
4- now lets create a new file in the same directory called when_user_login.module include the following code
/**
* Implementation of hook_user().
* #see http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_user/6
* for more details
*/
function when_user_login_user($op, &$edit, &$account, $category = NULL) {
switch($op){
case 'insert' :
// now any code we will write here will be implemented when new user register
// you can access the new user information by {$account} variable
// E.g $account->uid include the id of the new account that register
break ;
}
}
good luck...hop that will help you (don't forget to enable the module)

Resources