Silverstripe FulltextSearchable add custom fields - content-management-system

I need a custom field to be FulltextSearchable. Therefore I tried this code as described in the FulltextSearchable class:
Object::add_extension('Page', "FulltextSearchable('SearchableContent')");
then run dev/build.
Basically Fulltext Search seems to work. But the content of the custom Field 'SearchableContent' seems never to be checked.
Of course I enabled FulltextSearch first by:
FulltextSearchable::enable();
Thx,
Florian

All SiteTree classes have their search columns define in FulltextSearchable like:
$defaultColumns = array(
'SiteTree' => '"Title","MenuTitle","Content","MetaTitle","MetaDescription","MetaKeywords"',
'File' => '"Title","Filename","Content"'
);
so I don't think SilverStripe will pick up on your extra column. Unless you edit the FulltextSearchable but that's probably a bad idea... or just create a custom search function like for plain DataObject so you can specify exactly which columns to search on:
silverstripe dataobject searchable

Related

TYPO3 field helpers / hints / tips

since I'm pretty new to TYPO3 I'd like to know is there a possibility of adding simple text hints / tips below any type of field, something like this, for Nickname input field:
Thank you in advance!
Out of the box, not yet.
We are discussing a generic way to do so as we speak, but right now you'd need to create your own renderType for FormEngine.
Given the amount of PHP knowledge you have this is easy to intermediate.
Here are the steps:
Step 1: add your own formEngine Type class in ext_localconf.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1463078603] = array(
'nodeName' => 'ApparelCalculation',
'priority' => 40,
'class' => \T3G\Apparel\FormEngine\ApparelCalculation::class,
);
The number 1463078603 should be unique, so a good idea is to use the current unix-timestamp for that.
Step 2: Instruct your field to use that renderType
Add a TCA override file in YOUR_EXTENSION/Configuration/TCA/Overrides/tt_content.php (in this case we're overriding tt_content, thus the name. If you want to reconfigure another table in TYPO3, use the filename according to the tablename.
Add something along this:
$GLOBALS['TCA']['tt_content']['columns']['header']['config']['renderType'] = 'ApparelCalculation';
See how the renderType name is identical to what we registered in step 1.
Step 3: Render what you like to render
I'll add the configuration of my special case class here, but I will cover the important things later in this post:
It might be helpful for your case to copy from backend/Classes/Form/Element/InputTextElement.php since that seems to be the element you want to put your tip to.
<?php
namespace T3G\Apparel\FormEngine;
use T3G\Apparel\Calculation\Calculation;
use TYPO3\CMS\Backend\Form\Element\AbstractFormElement;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class ApparelCalculation extends AbstractFormElement
{
/**
* Renders the Apparel Calculation Table
*
* #return array
*/
public function render()
{
$resultArray = $this->initializeResultArray();
$calculator = GeneralUtility::makeInstance(Calculation::class);
$resultTable = $calculator->calculateOrder($this->data['databaseRow']['uid']);
$resultArray['html'] = $resultTable;
return $resultArray;
}
}
I won't focus on things outside the render()method, because that's just plain PHP.
It is important to call $this->initializeResultArray(); first, so TYPO3 can work its magic to gather all the data.
From here on I'd suggest to use xdebug to get a grip of what you have available in that class.
The amount of information is very dense, but you will have everything there you need to build even the craziest stuff.
Now that you know how everything plays together you might think about extending backend/Classes/Form/Element/InputTextElement.php with plain PHP, grab the result of the parent render() call and simply add your tip to it.
Enjoy :)

SugarCRM - Custom Print Layout

I created a model in SugarCRM and I need to print the details view. But this must be printed with a different layout.
It must have the company logo for example, if I just wanted do print the bean information, the default print would be sufficient, but I need something closer to a report, because this info will be given to the costumer.
I would like to know if there is a way to create a printing template, and if there is, how can I create one?
Thanks for your help, if you need more information please comment.
rfnpinto
Even in SugarCRM CE you can leverage the included Sugarpdf class, which is an extension of TCPDF.
If you have SugarCRM Professional you can find examples of this in the Quotes module. If not, you're flying blind, so I can give you the gist of it.
Using the Contacts module as an example, create /custom/modules/Contacts/views/view.sugarpdf.php with contents like the following:
<?php
require_once('include/MVC/View/views/view.sugarpdf.php');
/**
* this defines the view that will drive which PDF Template we use
*/
class CustomContactsViewSugarpdf extends ViewSugarpdf{
public function display(){
$this->sugarpdfBean->process();
$this->sugarpdfBean->Output($this->sugarpdfBean->fileName,'D');
sugar_die('');
}
}
Create /custom/modules/Contacts/sugarpdf/sugarpdf.pdfout.php with contents like the following:
$contact = BeanFactory::getBean($_REQUEST['record_id']);
if(empty($contact->id)){
sugar_die('Could not load contact record');
}
$name_str = "<p><strong>Name: {$contact->name}</strong></p>";
$this->writeHTML($name_str);
$this->drawLine();
}
function buildFileName(){
$this->fileName = 'ContactPDFOut.pdf';
}
}
From there, you can print a PDF document per your format if you hit the URI index.php?module=Contacts&action=sugarpdf&sugarpdf=pdfout&record_id=1234
Once that's working in the way you want, you can add a button the Contacts Detailview to access that URI more easily. Dig into /custom/modules/Contacts/metadata/detailviewdefs.php and find the existing buttons array. It'll look something like this:
'buttons'=>array('EDIT', 'DUPLICATE', 'DELETE', 'FIND_DUPLICATES'
Just enhance this with your own button and hidden input
'buttons'=>array('EDIT', 'DUPLICATE', 'DELETE', 'FIND_DUPLICATES',array(
'sugar_html'=>array(
'type' => 'submit',
'value' => '(Wrongfully Hardcoded Label) Print PDf',
'htmlOptions'=>array(onclick => 'this.form.action.value=\'sugarpdf\';this.form.sugarpdf.value=\'pdfout\'')
)
)
...
The hidden array should be part of $viewdefs['Meetings']['DetailView']['templateMeta']['form'] and defined like so:
'hidden' => array('<input type="hidden" name="sugarpdf">'),
I haven't tested this recently but this is the general idea of adding custom Print PDF abilities to any particular screen within SugarCRM. TCPDF options are pretty extensive and forming the template just right is going to be very tedious, but I think once the "plumbing" is working here you'll figure that bit out, but feel free to ask followup questions.

How to add a custom field button to a field in SugarCRM

I looked through the developer blogs and I can only find ways to create a custom global form button or to replace a field with custom code. I don't want to replace the field, I want to add a button beside a field.
Here's what I have in mind:
[Date Field][date_picker_button] [time field][time_is_now]
The button I want to add is the time_is_now, allowing the user to populate the time field with the current time.
I have tried updating custom/modules/Notes/metadata/quickcreatedefs.php with:
array (
'name' => 'billable_start_c',
'label' => 'LBL_BILLABLE_START',
'customCode' => '<button</button>',
)
But this replaces the input field with the custom code. I could just put in the stock code and then my custom code, but date fields use yui and a widget, so I'd prefer not to.
Is there anyway to do something like:
'customCode' => '{default} <button></button>',
so that the default code gets output and then the custom code?
You could create a new SugarField template, which will essentially allow you to create the markup for your field. If you named your SugarField TimeIsNow, you could create a field with that type (instead of text,int, date or whatever). You should take a look at some of the other SugarFields to see how they are formatted, but it's really just HTML. When the field is set to that type, it pulls in that HTML template. You can tie your JS to the onclick function. Sugar is very easy to customize, so I definitely wouldn't get in the habit of solving all your customization needs this way...It's another way to look at it though.
Don't use custom code if you can help it. Either copy over the tpl to custom/modules/[yourmodule]/tpls/[yourtemplate] and code the bitton in there or use an after_ui_frame hook and some js to insert you custom button into the DOM.

How do I get a regular Checkbox in a Zend Form?

I have a form in Zend_Form that needs some checkboxes and I'd like them to be regular old checkboxes. You know, you give em a name and a value. If they are checked your post data contains name=>value.
Zend_Form is generating two inputs fields. One, the checkbox with a value=1 and the second a hidden input with a value=2. Both have the same name. I understand in theory how Zend expects the checkbox to work, but that's not how I expect it to work and it's not how I want it to work. How do I get my old fashion HTML checkbox back?
I have tried using $this->createElement, $this->addElement and creating a Zend_Form_Element_Checkbox manually. None allow me to set the checkbox's value and all generate the hidden input.
The final and REALLY correct answer is to add an option to the element :
$this->addElement('checkbox', 'my_element', array(
'label' => 'My Element Label',
'name' => 'my_element_name',
'disableHidden' => true
));
Zend_Form_Element_MultiCheckbox is what you're looking for.
The standard Checkbox element is meant to represent "yes/no" scenarios.
You could extend Zend library and add your own custom form element to render it just like you expect it. I did it for having a date field and it worked just fine.
I wonder why that does not work for you. You can set the values to anything you want (setCheckedValue() and setUncheckedValue()). So the only difference to normal checkbox is
if (null == $this->_getParam('checkbox', null)) {
//vs.
if ($unchecked == $this->_getParam('checkbox')) {
What exactly are you trying to do?

Disable translation of Zend_Navigation elements

Is there any easy way to disable translation of some of the Zend Navigation elements?
e.g. in this case
$page = new Zend_Navigation_Page_Mvc(
array(
'label' => $blogPost->alreadyTranslatedTitleFromDb
// ...
)
);
$container->addPage($page);
Now, when I use:
$page->getLabel();
the label is translated twice. The same for breadcrumbs, sitemaps etc.
I wrote a patch with unit tests for this:
http://framework.zend.com/issues/browse/ZF-10948
If you want only some specific elements to be disabled, i think that only way is to use a partial view script and create your own logic for the menu.
You may add custom properties to the pages. Example: add a property doNotTranslate and in your view script check for this property to know if element should be translated or not.
More info about partial view script is available at http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.initial.navigation.menu