How to add a main menu option in Mantis BT - mantis

I am confused either to create a new plugin or make some changes to the source code to add a menu option.
What should i do to add a main menu option in Mantis BT?

If all you need is a menu item pointing to a static link, the easiest way to do this is via configuration; add the following code to your config_inc.php file:
$g_main_menu_custom_options = array(
array( 'Link text', ANYONE, 'http://example.com' ),
);
Please refer to the Admin guide for details.

Related

Reading and showing data from a custom module

I'm new to a Contao project, and the only dev at the project....
A custom module is created. For this custom module there is a data entry form (defined in a php file in the dca folder), in which a user can enter all the data which is then stored in a custom table.
The code for the module follows the layout stated in the blogpost 'Create a custom module - the basics' (http://blog.qzminski.com/article/create-a-custom-module-the-basics.html).
I've seen a PHP page (in the templates folder) which gets all the data from the custom database table (gets autoinjected via a variable?) and formats that in a html table.
That is what is built so far.
Now what I want to do is to create a display page for an individual item. Normally that will be:
create a link in the existing html table (with the id of the record)
which links to a new page (so for instance
pagenamewhichidonotknow?id=34)
and on that page, receive the id which is sent by the link (get it from the querystring?),
get the data from the custom databasetable (don't know how)
and then create a nice page (do know how to do this ;-))
I realize this is a large question, but I really don't know where to start.
Googling shows me a lot of pages with this warning "This guite was written for Contao 2.x and a lot of it's information is outdated! Read with care and only use as a general-purpose guide." and other pages are in German, which is, despite having learned it for 3 years in highschool, not my usp.
Any help is appreciated.
I hope I get you well. To achieve what you want, you will need to create two frontend modules, listModule and detailsModule and two pages, listPage and detailsPage therefore create these two pages in the backend(site structure). You will add listModule to the listPage and the detailsModule to detailsPage.
Never hardcode the page id unless you have no option.
Lets start on how to link to the detailsPage by creating the listModule and adding it to the listPage
Create /system/modules/my_module/dca/tl_module.php
Add the following code and save
$GLOBALS['TL_DCA']['tl_module']['palettes']['my_module'] = '{title_legend},name,headline,type,linkToDetail;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space';
$GLOBALS['TL_DCA']['tl_module']['fields']['linkToDetail']=array(
'label' => &$GLOBALS['TL_LANG']['tl_module']['linkToDetail'],
'exclude' => true,
'inputType' => 'pageTree',
'foreignKey' => 'tl_page.title',
'eval' => array('fieldType'=>'radio'),
'sql' => "int(10) unsigned NOT NULL default '0'",
'relation' => array('type'=>'hasOne', 'load'=>'eager')
);
This will create a column in your custom table that you will use it later to access the page ID in the template
Run the install tool.
Work on any errors that may arise. If none, go to next
Create the frontend module according to this url Front end module
In the compile function do as below
protected function compile(){
$objItems = $this->Database->execute("SELECT * FROM my_custom_table");
if (!$objItems->numRows)
{
return;
}
$arrItems = array();
// Generate item rows
while ($objItems->next())
{
$objPage = \PageModel::findPublishedById($objItems->linkToDetail);
$arrItems[] = array
(
'linkToDetail' => $objPage->getFrontendUrl('itemId='.$objItems->id),
);
}
$this->Template->items = $arrItems;
}
please note the itemId parameter added to the url
Create a template /system/modules/my_module/templates/my_template.html5
and you will be able to access easily the items
<?php if($this->items): foreach ($this->items as $item): ?>
<div class="item">
<?php if ($item['linkToDetail']): ?>
Please take me to the details page<?php endif; ?>
</div>
<?php endforeach; endif; ?>
Now go to themes -> modules ->new module and create a new module. I am assuming you have followed the instructions in that link on how to add your module to your module list. Assuming you added to the miscellaneous group, select your module. You will see a page picker with label 'linkToDetail'. select the detailsPage you created in the beginning.
Go to articles -> listPage -> new select 'module' as the element type and the choose your listModule above. We are good here. preview your page and you should be good.
Now lets build the detailsModule and add it to the detailsPage
Follow all the steps above only that in the compile function of the details module, you will select the details data as follows``
$objItemDetails = $this->Database->execute("SELECT * FROM my_custom_table where id=".\Input::get('itemId'));
step 7,8 and 9 are same.
This will help in the case where details page changes in times of ID. It makes it dynamic enough.
Hope this helps
To get list of items in the frontend:
Step 1 / create a List-Module:
go to "themes"
click the gears-icon
create a new modul
give it a name
choose the modul-type from the dropdown
(the name of the model to choose should be like this:
"yourCustomModulNameList" or similar)
Step 2 / embed the new List-Module into an Article:
go to articles in the main-menu
edit the article which should contain the list
choose new content-element
choose "Modul" as type
select your named modul
... to create a display page for an individual item, the steps are nearly the same:
create a reader-modul
insert this reader-modul on a new page (in a new article)
tell the previous created list-modul where the reader-modul is
hope this helps :)

How to replace a code in a specific page using sublime text 3?

I am using sublime text 3 as my editor and I I dont know if sublime has a capability to find and replace a code in a specific page or current page. For example I have a page that compose of 850 lines and I want to replace a specific variable value. When I used the command Ctrl+Shift+F it opened the search and replace panel. And in the 'WHERE' it has only options for
'Clear',
'Add Folder',
'Add Include Filter',
'Add Exclude Filter',
'Add Open Folder',
'Add Open Files'
I tried all of them but, where can I find options for a specific page only?
As you can see in the Key Bindings preferences file, Ctrl+Shift+F it's binded panel:find_in_files whereas Ctrl+H it's binded to panel:replace.
So, just use Ctrl+H to replace in the current file, or you could also use menu Find > Replace.
In addition, Ctrl+H it's a common binding for replace in many other editors.

Rich Text Editor in Rails: Show the target tab for links in the link dialog window

I am using Activeadmin with Rich Editor.
When I add a link to my text within the window of the editor i cannot set how the link is being opened - wether it is in a new tab or a new window ..
I understand that the Rich editor derives from CKEditor with certain features being disabled and that these features can be reenabled.
Also I know, that this particular feature is set in the config by the line
config.linkShowTargetTab = true
I am just not sure on where to put it exactly so that it is enabled globally.
Thanks for any advice on this.
In the gem source (lib/rich.rb) you can see the default buttons defined in ##editor[:toolbar]:
##editor = {
...
:removeDialogTabs => 'link:advanced;link:target',
...
}
If I delete ";link:target" the Tab is shown in my app.

HTML hyperlink is not operning in a new tab

echo "<td align = 'center'><a href='edit/edit_rrdalert.php?id=".$alertid .
"&title=".$inst_title."&cat=".$categories["$cat"]."'target='_blank'>edit </a>";
I want to open the link in a new tab as edit/edit_rrdalert.php?id.
It shouldn't be your call to decide whether the link should open in a new tab or a new window, since ultimately this choice should be done by the settings of the user's browser. Some people like tabs, some other like new windows.
Using _blank will tell the browser to use a new tab/window, depending on the user's browser configuration, and also depending on how they click on the link (middle click, ctrl+click, normal click).
but if you wish to do it set the target attribute of your element to "_tab"
EDIT: It works, however W3Schools says there is no such target attribute: http://www.w3schools.com/tags/att_a_target.asp

Ruby on Rails: Cucumber: how do I follow a link that opens a new window?

I have a link that opens in a new window, and I need to test the part of my app that is within that new window.
Any suggestions will be much appreciated.
Define a step that contains this code:
page.driver.browser.switch_to.window (page.driver.browser.window_handles.last)
switch_to is a selenium command that allows you to change over to a new window
window_handles returns a list of currently open windows
I realize this is a very old post, but here's a Cucumber step definition using Capybara and the Poltergeist driver:
And /^I follow "([^"]*)" to the new window$/ do |link|
new_window = window_opened_by { click_link link }
switch_to_window new_window
end
Could you just validate that the link has it's target set to _blank?

Resources