EBook::EPUB.pm add_navpoint use - perl

I have one large .xhtml file consisting of many chapters. There are div tags with e.g. id="article2" on some of them. I am now trying to make an ebook out of it. EBook::EPUB is a nice package that helps greatly.
And I have most of it working well. Alas, the following does not work:
for (my $cnt=1; $cnt<=$#chapters; ++$cnt) {
$epub->add_navpoint(
label => 'Chapter '.$cnt.": $memotitles[$cnt]",
id => 'article'.$cnt,
content => 'text.xhtml',
play_order => $cnt );
}
When I open the epub file in iBooks, it shows me the labels, but clicking on any of them does not move me to the right page in the epub file.
I know that it is possible to get ids from a book where each chapter is its own .xhtml file. alas, is it possible to get ids to reference waypoints (chapters) from inside the same .xhtml file? Or do I really have to break my large .xhtml file into many smaller ones?
Advice appreciated.

"content" property should have id of the element in the xhtml page. So something like this should work:
for (my $cnt=1; $cnt<=$#chapters; ++$cnt) {
$epub->add_navpoint(
label => 'Chapter '.$cnt.": $memotitles[$cnt]",
id => 'article'.$cnt,
content => 'text.xhtml#article' . $cnt,
play_order => $cnt );
}

Related

How can I set the icon for a content element in TYPO3?

In tt_content I have added something like this, and set the core icon 'content-image':
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem(
'tt_content',
'CType',
[
'My Element',
'myelement',
'content-image'
],
'textmedia',
'after'
);
And this works in the 'Type' dropdown menu. However, when in Page or List view it always shows the default text icon. How do I change this to match the type menu?
Just found another question with a real good answer - mainly the same
as mine, but better structured - have a look:
How to setup icons for content elements or plugins in a TYPO3 extension
You may revisit https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/ContentElements/AddingYourOwnContentElements.html with a full overview.
The \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem() registers the icon only for the select field.
For the "new content element" wizard you have to provide a proper TSconfig part https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/ContentElements/AddingYourOwnContentElements.html#add-it-to-the-new-content-element-wizard
// example - you must adopt for your element
mod.wizards.newContentElement.wizardItems {
// add the content element to the tab "common"
common {
elements {
examples_newcontentelement {
iconIdentifier = content-text
title = LLL:EXT:examples/Resources/Private/Language/locallang.xlf:examples_newcontentelement_title
description = LLL:EXT:examples/Resources/Private/Language/locallang.xlf:examples_newcontentelement_description
tt_content_defValues {
CType = examples_newcontentelement
}
}
}
show := addToList(examples_newcontentelement)
}
}
If you want to use a custom image, you have to register it. Either in ext_localconf.php with proper icon calls or depending on the core version with the simple Configuration/Icons.php file.
See for 11.5+ https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Icon/Index.html or before see https://docs.typo3.org/m/typo3/reference-coreapi/10.4/en-us/ApiOverview/Icon/Index.html
The next part is then TCA configuration for the specific table. Generic table icon file is configured with:
// or $GLOBALS if done as TCA Override for a existing table
return [
// ...
'ctrl' => [
'iconFile' => '',
// ...
],
// ...
https://docs.typo3.org/m/typo3/reference-tca/main/en-us/Ctrl/Properties/Iconfile.html
Table with types can have different icons per types, which can be set with typeicon_classes
https://docs.typo3.org/m/typo3/reference-tca/main/en-us/Ctrl/Properties/TypeiconClasses.html#ctrl-reference-typeicon-classes - however, this depends on the type field. For tt_content this is "CType". So this helps only for real content elements which registeres as own CType - and not as list CType with a subtype list_type. For extbase plugin this is done with the proper plugin registration in Configuration/TCA/Overrides/tt_content.php:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'ExtkeyInCamelCase',
'PluginIdentifier',
'plugin title',
// icon
'my-icon');

TYPO3 preview image of inline records

A tt_content custom content element (imageslider) has IRRE slides.
The slide record has a title and an image (filereference).
Is it possible to preview the image of the IRRE record?
The previewRenderer class seems to be oriented only on the page view.
typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php shows a TCA setting for headerThumbnail
However this TCA doesn't produce the headerThumbnail.
'appearance' => [
'headerThumbnail' => [
'field' => 'image',
'width' => '45',
'height' => '45c',
],
So a userFunc or something is needed to retrieve the fileUid for field? Or is there an easier solution possible?
[EDIT] An IRRE record could of course have multiple images. So I guess this should be a feature for the InlineRecordContainer class, like the previewRenderer class to adjust the look and content.
Nice hint, that there should be custom thumbnails possible...
After diving a bit deeper in InlineRecordContainer, it seems to be clear, that this can't work (anymore?). There are (in v10/v11) the following lines:
// Renders a thumbnail for the header
if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] && !empty($inlineConfig['appearance']['headerThumbnail']['field'])) {
$fieldValue = $rec[$inlineConfig['appearance']['headerThumbnail']['field']];
$fileUid = $fieldValue[0]['uid'];
For the UID of the thumbnail, the first array entry in the given field is used. But when debugging $rec (=$data['databaseRow']), we see, it is just the raw record, which means a FAL-field will not be an array but only an integer that counts the relations...
IMO this is a bug. I have just reported it: https://forge.typo3.org/issues/96188

How to add condition for a field in the layout of SuiteCRM.?

In that in studio I have created some fields in one module and i also add those fields in Layout. but i want to display the fields according to the selection, for example: if user select option-1 from dropdown field then it has to display say only three field, and if user select option-2 from dropdown field then it has to display say six fields. so i need to add some condition in the layout field. but i can't find any option there.. please help me to find out.
i also attached the example image below.
If you are using sugar 7.6 I can help,
You want to change the fields according to drop down values if i am not wrong .
For that you have to right a code in "record.js" and "create-actions.js" files . just write a js function.
This is an example for crerate-action.js
({
extendsFrom: 'CreateActionsView',
initialize: function (options) {
this.model.on("change:dropdown", this.renderFields, this);
},
renderFields: function () {
// write your code here
},
})
You need to modify the view definitions to add a script into the edit view of your module.
Example:
$viewdefs ['<Module Name>'] =
array(
'<View Name>View' =>
array(
'templateMeta' =>
array(
...
'includes' =>
array(
0 =>
array(
'file' => 'path/to/your/script.js',
),
1 =>
array(
'file' => 'path/to/your/script.js',
),
),
...
),
...
),
...
);
You then can use jQuery or any javascript library to hide or show the fields. if you are using SuiteR or SuiteP theme you can simply add/remove the hidden class to the elements.
Just make sure that you add all the fields into your view which you wish to show or hide.
To make this upgrade save modify or create
custom/modules/module name/metadata/editviewdefs.php for the edit view
custom/modules/module name/metadata/detailviewdefs.php for the detail view
There are many defined ways in sugarcrm, as you have created new fields, all you need to add dependencies on those fields like
$dictionary['YOUR_MODULE_NAME']['fields']['YOUR_FIELD_NAME']['dependency']='(equal($YOUR_DROPDOWN,"OPTION_1"))
see
http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.7/Architecture/Sugar_Logic/Dependency_Actions/SetVisibility/#Visibility_Dependencies_in_Field_Definitions
This can also be added through Studio.
Go to Studio > module > fields > YOUR_FIELD > Dependent and add dependency.

How to apply a different wrap in a TMENU for certain items only?

In a TMENU, I would like to apply a special wrap to certain pages only.
So of
Home
-- This
-- That
-- Such
-----A
-----Thing
Only the page "Such" would have this wrap (with a special class or an icon for wrapItemsAndSub).
Ideally, this could be done from the page tree / from the CMS. Or by pid.
But I think it's not possible to reach into the TMENU in an easy way?
OptionSplit is not an option, as it's only a few special pages.
Can this be done and how?
You must use CASE object here and apply that to property/wrap which has stdWrap.
Look at this example.
NO {
wrapItemAndSub.cObject = CASE
wrapItemAndSub.cObject {
key.field = uid
default = TEXT
default.value = <li>|</li>
// for page uid = 99
99 = TEXT
99.value = <li class="special">|</li>
}
}
You can use this way to every element that has stdWrap.
BTW: as pgampe said it can be of course done more universal with some checkbox or even dropdown when you select class name.
This is a short tutorial for checkbox. For this tutorial I assume the extension name is "t3_local"
STEP 1
In ext_tables.sql file add:
CREATE TABLE pages (
tx_t3local_special tinyint(4) DEFAULT '0' NOT NULL,
}
Then go into Extension Manager into your extension and update database to create the new field in pages table.
STEP 2
In ext_tables.php file add:
$tempColumns = Array(
'tx_t3local_special' => Array(
'exclude' => 1,
'label' => 'Some label for special',
'config' => Array(
'type' => 'check',
'default' => 0
)
)
);
t3lib_div::loadTCA('pages');
t3lib_extMgm::addTCAcolumns('pages', $tempColumns, 1);
t3lib_extMgm::addToAllTCAtypes('pages', 'tx_t3local_special');
It is ready now to use in the backend. After you clear the TYPO3 cache you should see the checkbox in page properties. Now we must only use it to build our menu in frontend.
STEP 3
Now it all depends what do you want to do with this switch. Assuming that you want to add a class for li here is a little trick how to allow to use several such switches to accumulate different classes.
NO.wrapItemAndSub.stdWrap {
prepend.cObject = LOAD_REGISTER
prepend.cObject {
special1class.cObject = TEXT
special1class.cObject {
value = special1-class
if.isTrue.field = tx_t3local_special
}
special2class.cObject = TEXT
special2class.cObject {
value = special2-class
if.isTrue.field = tx_t3local_special2
}
}
append = TEXT
append.value = <li class="clearfix {register:special1class} {register:special2class}">/li>
append.insertData = 1
}
NOTE
As you now know how to add switches to page property you can also use them to turn off/on some functionality on page. For example I use such switch to turn on/off breadcrumbs for page. In this example the if checkbox is checked the breadcrumb of off.
For this working you must remember to add the field name to typo3conf/localconf.php file (or LocalConfiguration.php in 6.x)
$TYPO3_CONF_VARS['FE']['addRootLineFields'] .= ',tx_t3local_breadcrumb';
And the TS:
lib.breadcrumb = COA
lib.breadcrumb.stdWrap.if.isFalse.data = page:tx_t3local_breadcrumb
lib.breadcrumb {
...
...
...
}

Zend_Navigation: Having trouble getting breadcrumbs to render using multiple containers [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Zend Framework - multiplate navigation blocks
I'm trying to make breadcrumbs render in my application ( they don't show up anywhere, not even the homepage, which has a corresponding Zend Page Uri object ), which has multiple navigation areas - primary and utility. For the menu generation, I have a MenuController which I render with from within the layout using:
$this->layout()->utility = $this->action('render', 'menu', null, array('menu' => $this->utilityId));
$this->layout()->nav = $this->action('render', 'menu', null, array('menu' => $this->mainMenuId));
The utilityId and mainMenuId properties are numbers, grabbed from a database.
The Menu controller's render method just builds an array and creates a Zend Navigation object, then invokes setContainer and sets it to that container. This is pseudo code because it's rather long:
// MenuController.php
private function renderAction() {
$itemArray[] = array('label' => $label, 'uri' => $uri ); // in a loop
$container = new Zend_Navigation($itemArray);
if ( $container instanceof Zend_Navigation_Container ) {
$this->view->navigation()->setContainer( $container );
$uri = $this->_request->getPathInfo();
$item = $this->view->navigation()->findByUri($uri);
$item->active = true;
}
}
So this render method is called twice from within the layout for the utility and nav.
EDIT:
I think the issue is that I need to specify the $container so my code would be
$this->navigation($container)->breadcrumbs();
However because I'm using $this->action('render', 'menu' ) the $container variable is set there and not returned, is there a way I can specify the container some other way? Possibly using $this->layout()->nav and a property in that which points to the container.
This looks like it's the same issue and someone suggests setting/getting them with Zend_Registry, perhaps I'll try this out.
I suspect you don't have a navigational hierarchy. You need pages within pages.
e.g.
Home Page
[pages] => Sign In
[pages] => Forgot Password
=> Create Account
[pages] => Confirm Account Email
=> Email Confirmed
With the above, breadcrumbs will be rendered on all active pages except for the Home Page... all pages if you do this:
$this->navigation()->breadcrumbs()->setMinDepth(0); // don't skip the root page
Or maybe it's something else, but it's hard to say. I hope that helps, though!
This is probably a dirty solution, but I manually set the container reference using Zend_Registry like so:
Zend_Registry::set( 'nav' . $menu, $container );
And spit it out like so:
$main = Zend_Registry::get( 'nav' . $this->mainMenuId );
echo $this->navigation( $main )->breadcrumbs()->setMinDepth(0);