I inherited a Drupal5 site and have been tasked with making some changes, but I'm unable to figure out where to start looking.
On many pages there is a menu available to administrators that allows you do do certain actions:
Overview
Specialists
Resources and Tools
In the Field
News
Events
Courses
Multimedia
Edit
Track
Workflow
Settings
However, on some sections, there are different options:
Preview
Layout
Settings
Layout settings
Advanced
Context
Content
Export
I need to add (Edit, Track, Workflow, Settings) to the second menu, but I'm not sure how to do that.
I see in page.tpl.php there is region for $tabs, but I can't figure out how this gets built.
From what I can tell, the theme is based on the Zen STARTERKIT theme.
The $tabs variable normally gets populated with menu entries of type MENU_LOCAL_TASK.
Take a look at the menu system, and especially at hook_menu() to get a basic idea. It boils down to a mapping of callback functions to paths. If an URL matches a path defined in hook_menu (can contain placeholders!), the callback function registered for that path will be called to generate the content for that URL.
The 'type' of the hook_menu item defines how the path/callback combination is represented in the system. It can be a MENU_CALLBACK, which would mean just the registered path/callback combination, but no corresponding 'real' menu entry. A MENU_NORMAL_ITEM, would be the same, but with a 'standard' menu entry, e.g. in the navigation menu. A MENU_LOCAL_TASK is the same, but the corresponding menu entry usually shows up in the $tabs and not in a menu.
All MENU_LOCAL_TASK that share the same base path will end up as a group of tabs. So if you had paths like:
some/path/tab1
some/path/tab2
some/path/tab3
and all of these where defined as MENU_LOCAL_TASK, you would see one tab for each of them on each page they represent.
So to find the places you need to modify/enhance, you should search your codebase for all hook_menu() implementations that define the paths where those tabs show up. Note that they need not all be defined at the same place, but could come from different hook_menu implementations in different modules. Than you'd need to add menu definitions for the tabs you want to add, mapping the relevant paths to callback functions. The callback functions would return the content of the pages that the user should see when clicking the tabs.
If you are displaying node, usually there is already the Edit link in the $tabs, since its not present that might be something else (some kind of layout module). You need to add Edit/ Track options to edit/track what kind of content? Specific node or what?
Related
I have a menu in joomla that appears on all pages. Some of the items in the menu should be the same on every page, while others need to be dynamically updated based on the page the user is on. I am trying to create an override for the "external url" menu item type (listed under system links), that would allow me to create a menu item parameter the user could populate. Then, I could use this parameter in the menu template to determine what needs to be added to that particular link.
I understand Joomla overrides for the most part, but I can not figure out where the xml file for these system link menu items is located. If my understanding is correct, overrides should be stored in templates > myTemplate > html > com_myComponent or mod_myModule. I would assume if I knew what component the system links fall under, I could create an override for the xml file. Is this correct or way off?
TL;DR: Where is the xml file for menu item type "external url"?
It seems there is no specific xml-files for the system links, as they are defined directly in
administrator/components/com_menus/views/menutypes/view.html.php
which means there is no xml-file to override. You can, however, override the view class MenusViewMenutypes, which is defined in the view.html.php-file. This is done by writing a system plugin loading a file containing the same class. The recipe is simply and beautifully described here.
In the pages .tpl.php of my theme i can find several lines like
render($action_links)
displaying whole pages with a single command. Sometime i saw that the render argument is a block from my theme .info, but other times i see arguments i cannot identify that render default pages or elements of drupal.
How it works? And where i can find a list of default displayable pages?
In particular, i needed to display the content of the default drupal page "add content" in one of my pages, and i'm pretty sure i can do it using this render method, but i cannot find the correct argument.
EDIT: I found something like
drupal_render(node_add('NODE_TYPE'));
that seems to allow the display of a node add form, but what i need is the main add content page, containing the list of all the type of nodes that a user can add.
Are you new to Drupal? When I read your post, I'm almost sure that you have missed something with the Drupal's working. The variables you found in render() functions are "calculated" somewhere else in the code (in the modules part for the most).
You cannot find a list of constant variables to display them just like this.
I found this article about these mysterious variables that are rendered and I hope it will help: http://newsignature.com/articles/the-magic-behind-drupals-render-elements
If you just want to display the "add content" form somewhere on your site, just call its path (node/add).
EDIT AFTER CLARIFICATIONS:
First of all, you can set on which page you want the user lands after login. (I don't know why you're still talking about user profile template. Maybe I missed something again.)
But if I did understand what you're trying to achieve, I'll do that:
Create a menu (or simply use the "Navigation" menu that seems to be exactly what you need) with all the actions users can do. And I'll place this menu in the main content region. Do create a menu, go to Administration>Structure>Menus>Add menu. And add links like "node/add/article" or "node/add/news" or "node/add/page" or whatever your content-types are.
Place this menu in the region you want. If you want it to be like the main content of the page, place it in the main container. To do so, go to Administration>Structure>Blocks> Drag and drop your menu in the right region and Save.
Configure this block to appear only on the front page (the first page on user arrives after logged in) if you want so. To do so, in the Blocks administration page, click on "Configure" next to your block and check "show block on specific pages: Only the listed pages" and write down <front>
Create roles and permissions for your different sorts of users. That will automatically show them the links they are allowed to see. To set permissions, go to Administration>People>Permissions and check in the "Node" section which content-type each role can create.
I hope I didn't forget anything. Please tell me if it is clear enough.
I've got a desktop joomla site which uses the database called 'mydatabase'. However, I've created another site for mobile version in a folder in the same host. Then:
www.mysite.com is my desktop webpage.
www.mysite.com/mobile is my mobile webpage.
Both sites, mobile and desktop, are single and independent joomla instalaltions, but they use the same db.
Then when I try to configure the default template to render my contents, I`ve got to choose between mobile contents or desktop contents, but not the two.
How can I render my both templates, so both sites work and live together?
Joomla stores most of its configuration options in the database, thus your question requires some coding to handle it. But let me get one step back.
1. The Joomla approach
Joomla allows you to define which pages show which menus. You could have a simple Joomla installation with SEF turned on, where the main menu is as it is currently in the root.
Then all you need in order to have a /mobile page with a different layout is
Create a new menu (not menu item, menu type) and name it SEF or Hidden; this will not be published anywhere.
Create a menu item with alias "mobile" in that menu.
This ensures your users will be able to surf to the page /mobile and access that menu item.
Now create a menu for the mobile part of your site, add menu items and choose the default template for each, and create a module to display it. Assign it to "Show only on the selected pages" and choose the /mobile page you just created and any others contained within the menu.
Then go back to the main menu module, and configure it to "Show on all pages except", and make the same pages selection.
Now you will have two menus, one for the desktop and the other for the mobile. Aside for the template assignment, they will be identical.
2. Third party extensions
There are third party plugins which allow you to define a different template based on several parameters: country, useragent, screen size etc.
In addition to what you find on the JED, many templates (mostly commercial ones) have a feature to define a custom layout for mobile users.
Whether you handle this with a plugin or with a template is a matter of personal choice; either will work very effectively and be more appropriate than the Joomla answer I outlined above as they will help you prevent duplication. Duplication in content or menu items is costly as maintenance and testing will be harder.
I think that the way you are doing it is very different from the normal Joomla approach (which would be have a responsive template or have the index.php of the template load different subfiles depending on device), but let's assume you have your reasons.
So you have the same database which means all of the menus are the same, all of the module assignments are the same, all of the template assignments are the same and the default template style is the same.
Now, in Joomla template styles are also stored. This is a json string of pairs with various template options.
Simple case, let's assume that both the mobile and desktop template have the same options.
Now in the templates folder of the mobile site we'll have the mobile template.
Call that mytemplate.
In the desktop site you have a the desktop template. Call it mytemplate. Install it ONCE.
So these templates have the same name but because they are in two different physical sites they are in two different physical templates folders, one in the mobile site and one in the desktop.
Now we make mytemplate style-1 the default.
In the mobile site this is always going to load the mobile template while in the desktop site it will always load the desktop template.
Now say we assign mytemplate style-2 to the news menu item. Again the appropriate template is used based on the actual site it is called from.
Now the trickier thing is if you do not have identical parameters. This is likely since the settings you need will be different. In this case, what you will need to do is make sure that the parameters defined in templateDetails.xml include both sets. So if you make a new style you need to always set the parameters for both templates. This is actually going to be helpful since you won't have to configure it twice.
I have a client who has a magento site that loads custom category pages and on one of them $this->getChildHTML('content') is dumping out a bunch of code after it loads the page. it's only on one page and it looks like its dumping out php closing tags.
getCurrentCategory()?> getCurrentChildCategories()?> count()):?> getIsActive()): $cur_category=Mage::getModel('catalog/category')->load($_category->getId()); $layer = Mage::getSingleton('catalog/layer'); $layer->setCurrentCategory($cur_category); $catName = $this->getCurrentCategory()->getName(); if($_imageUrl=!$this->getCurrentCategory()->getImageUrl()):?>
getCurrentCategory()->getImageUrl()):?>
getName()?>
setCurrentCategory($_maincategorylisting); ?>
I can't seem to find the page that has the error on it. I don't know where 'content' in getChildHTML is located. the category pages were made custom, and doesn't show any products, just an image of one of the products. i'd like to change these pages to show products and a whole bunch of other stuff, but i just don't know where these custom category pages reside. there are custom templates for each category, but they all use the same getChildHTML('content') call...
i tried downloading the whole site and doing a text search for bits of code on the category page, but found nothing. please help!
btw....if you could already tell, im new to magento and probably left a lot of important info out, so if you think i need to post more info, please say so.
thanks in advance!
"content" is the name given to a block which is defined in page.xml as a core/text_list (Mage_Core_Block_Text_List) block. The purpose of this block is to echo any child blocks assigned to it, and it does this without a template. Any layout file as well as layout updates in the database (see any category's Design tab) can contain instructions which are included on category pages and modify the children of this block.
See Alan Storm's knowledgebase article on MagentoCommerce.com and eventually graduate to his exhaustive book No Frills Magento Layout.
For general information you are in good company at Stack Overflow, and you can also rely on Magento U as a resource.
That depends on the theme, any extensions, and other custom code. Typically, getChildHTML('content') loads the "content" handler for the current layout. This could either be directly in catalog.xml, local.xml, or if it's an extension override, the extension's xml. It could also be a layout update in the Category itself on the backend.
Use Magento's debugging tools to output each block and their location from the Admin:
System -> Configuration
Change 'Current Configuration Scope' to the website view
Advanced / Developer
Debug panel: 'Template Path Hints' and 'Add Block Names to Hints'.
You can also add your IP address to the 'Developer Client Restrictions' section above it to limit this output to just your own IP. Once you save it, you'll see a lot of red-outlines.
View your broken category page and find the filename that wraps around the broken code.
I'm new to Drupal dev, and was trying to add an existing region variable to my module's preprocessor function.
Basically, I've created a new region for my site (here's the definition from within side my theme's .info file):
regions[feeds] = Feeds
From Administer->Blocks, I've added the blocks I want to the new "Feeds" region.
Then, from another module, the "Advanced Front Page" module, I'm trying to add some PHP to my "front page" inside this module. The Advanced Front Page module just allows the site to have a landing page, instead of immediately viewing a list of other site content, etc. I've enabled PHP for the content area, and then added the following:
<div>
<?php print $feeds; ?>
</div>
It does not print the "Feeds" region, and I believe it's because that region variable is not accessible from outside of the page.tpl.php file. So after looking around, I came upon these links:
http://drupal.org/node/223430
http://drupal.org/node/237391
From there, I tried to add a preprocessor function for the module "Advanced Front Page", which has a module name of "front_page" (or possibly just "front", I'm not 100% sure). Here's my preprocessor function, that I tried to add to both my template.php file, and the /modules/front/front_page.module file (not at the same time, mind you):
function front_preprocess(&$vars)
{
$vars['feeds'] = theme('blocks', 'feeds');
}
Regardless of where I've placed this file (template.php or front_page.module) it doesn't seem to do anything. Any idea where I might be going wrong?
There are several points to address in your question:
I'd second googletorps answer in that you should approach this in a different way.
The *_preprocess functions can only be used to manipulate/inject variables for templates or theme functions, e.g. page.tpl.php, node.tpl.php, theme_links(), etc. As the front_page module does not use a theme function or (special) template to render its output, you can not make the $feed variable there by means of a *_preprocess function.
Sidenote: With *_preprocess functions, naming is crucial. You need to prefix the function name either with the exact module name or the theme name, depending on where you declare it. So in your example, if you want to add a preprocess function to the module, you'd prefix it with 'front_page_', if you add it to your themes template.php, you'd add 'yourThemeName_'.
You could achieve what you want by creating the blocks directly from code in your frontpage content area. Instead of trying to output the (not available) $feed variable, you could call:
theme('blocks', 'feeds')
This will cause Drupal to return the themed blocks for the given region ('feeds' in this case). Note that this is still not a good way to do it, as even if you don't use the region in your page.tpl.php, it still gets created for every page request made to your site!
So I would go with googletorps suggestion, adding the new region only if there are other uses for it also. If I'd just wanted to add some blocks to the frontpage, I would not create a new region, but configure the blocks to show in the content region and simply restrict them to show only for <front> in their visibility settings.
I haven't tried the advanced front page module, but when dealing with regions, you shouldn't do what you have done. It's a bit hacky and actually not needed. I don't know how the module hook into the templating system, but your problem is probably getting region variables into it's scope. But instead of trying to get the region into the frontpage using the module, you should instead get it into your page.tpl.php. You can actually do what you first tried, but I would suggest that you alter it a bit like this:
<?php if ($feeds): ?>
<div id="feeds">
<?php print $feeds; ?>
</div>
<?php endif; ?>
I have improved in two ways.
By adding the if statement, you don't add empty markup. So you wont get an empty div if $feeds doesn't contain anything.
Adding id's to regions is a good idea. It makes styling them or their content a lot easier, also it adds semantic to your page which html is all about.
Now if you only want your blocks to be shown in the front page you can set that up in each of the blocks settings. So you could possibly just use a region that already exist, unless you want your blocks display a outside an existing region. When adding regions it's not a good practice to only add a region to a single page, instead it's much better to control when it's content should be shown. It might be that you don't need to create a new region, but simply can use one that's already made. Also if you want to make some template changes to your front page, you can also create the front-page.tpl.php where you can create a different template layout for your front page if you so desire.