How can I add images in my header 320x72(heightxwidth) in Magento 2? My header and footer file and showing in app->design->frontend-> or shopping\vendor\magento\theme-frontend-blank\Magento_Theme\layout.
Step 1. Make new theme in Magento 2 follow below directory
app / design / frontend / / / Magento_Theme / templates / html
Step 2. Copy header.phtml files from vendor\magento\module-theme\view\frontend\templates\html and paste in app / design / frontend / / / Magento_Theme / templates / html
Step 3. Now you can change header.phtml files.
Image can add in header by below code.
<?php
$_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$storeManager = $_objectManager->get('Magento\Store\Model\StoreManagerInterface');
$currentStore = $storeManager->getStore();
$mediaUrl = $currentStore->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
?>
<img scr="<?php echo $mediaUrl.'/image.jpg' ?>">
Related
I have to prevent loading backgrounds by style="" attributes in the frontend but still need to be able to set up background images from the cms.
TYPO3 has a default stylesheet (e.g. typo3temp/stylesheet_[hash].css?[timestamp] for loading CSS registred by TypoScript:
plugin.tx_myext._CSS_DEFAULT_STYLE (
.css {}
)
But is it possible to extend this css file from a Extbase Controller?
Unfortunately \TYPO3\CMS\Core\Page\PageRenderer has not such a functionality.
I also tried:
$GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_myext.']['_CSS_DEFAULT_STYLE'] = 'body {display:none}';
But it seems that the \TYPO3\CMS\Frontend\Page\PageGenerator generates the page before any content is called.
You can add this to $GLOBALS['TSFE']->additionalHeaderData array, it will add any content to head section of HTML doc, just make sure that used index is unique! so you have two soultions:
One is adding styles directly to head like:
$GLOBALS['TSFE']->additionalHeaderData['tx_yourext_styles_for_action_foo_bar']
.= '<style>body {background: orange;}</style>';
second is the same technique but in better edition, let's say that you have dedicated typeNum - 1234 which generates stylesheet file for given page as a standalone stylesheet file, so you can just include it as usually:
$cssUrl = 'index.php?id=' . $GLOBALS['TSFE']->id . '&type=1234';
$GLOBALS['TSFE']->additionalHeaderData['tx_yourext_styles_for_action_foo_bar']
.= '<link rel="stylesheet" type="text/css" href="' . $cssUrl . '" media="all">';
Of course you can use any other combination ;)
In the Typo3 backend I'm redering my email body with a Fluid template. In the following way:
$emailView = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
$templateName = 'path/to/email/template.html';
$extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$templateRootPath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($extbaseFrameworkConfiguration['view']['templateRootPath']);
$templatePathAndFilename = $templateRootPath . $templateName;
$emailView->setTemplatePathAndFilename($templatePathAndFilename);
$emailView->assignMultiple($variables);
$emailBody = $emailView->render();
In the loaded email template I'm making an absolute link to a page with the following line:
<f:link.action absolute="true" pluginName="name" extensionName="extName" pageUid="{PageId}" controller="Ads" arguments="{uid: uid}">Klik hier</f:link.action>
This is generating a working link only it is not processed by RealURL. Is it possible that is will be done?
You need a valid frontend context for realurl to work. Therefore I suggest that you move your email template to a page type and use a subrequest to render the HTML.
I've a multi domain TYPO3 CMS installation where every of the X page trees has it's own page template and content elements build with FluidTYPO3.
At the moment the backend user sees all the templates and elements provided by the different provider extensions. The question is now: is it possible to disable page templates and content elements by some user defined conditions (fx if we are on a subpage of page Y only show page template A and content elements B,D and F?
Markus
The solution is to have separate TS configurations for separate sets of templates.
See following example:
your_ext/Configuration/TypoScript/Set1/setup.txt:
plugin.tx_yourext.view {
templateRootPath = EXT:your_ext/Resources/Private/Set1/Templates/
partialRootPath = EXT:your_ext/Resources/Private/Set1/Partials/
layoutRootPath = EXT:your_ext/Resources/Private/Set1/Layouts/
}
your_ext/Configuration/TypoScript/Set2/setup.txt:
plugin.tx_yourext.view {
templateRootPath = EXT:your_ext/Resources/Private/Set2/Templates/
partialRootPath = EXT:your_ext/Resources/Private/Set2/Partials/
layoutRootPath = EXT:your_ext/Resources/Private/Set2/Layouts/
}
your_ext/ext_tables.php
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY, 'Configuration/TypoScript/Set1', 'Templates Set1');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY, 'Configuration/TypoScript/Set2', 'Templates Set2');
So, then you can include desired set at specified TS template in a tree. E.g. your structure is:
root
|
|- Home1 (TS Template)
| |
| |- Page 1
| |- Page 2
|- Home2 (TS Template)
|
|- Page 1
|- Page 2
Then you can include "Templates Set1" at your "Home1" TS template, but "Templates Set2" at your "Home2" TS template.
The only drawback: you can't use two sets at same time on same page.
More info at offcial manual.
Update 05.03.2015: A ticket was created to track issue with no possibility to unset custom CEs, and now this issue is finally solved.
So, taking an example from commit message above, one could do this:
# disable the "Alert" element:
plugin.tx_fluidbootstraptheme.forms.alert.enabled = 0
What I have done for a project is to generate a directory tree based on the site name:
site1
templates
layouts
Partials
site2
templates
layouts
Partials
I than created:
plugin.tx_yourprovidername.settings.sitename = site1
I could then use this in my template :
<f:layout name="{settings.sitename}/nameoflayout"/>
there is at least a way to hide elements and tabs in the new content wizard. Add this to your page tsconfig and make sure you include it in your page tree (properties > resources > typoscript configuration):
mod.wizards.newContentElement.wizardItems.common.show =
This line will hide the "common" tab in the new content wizard. If you group your ce templates accordingly you can controll which elements are shown for a given page tree. You can also hide single elements using ":= removeFromList(yourElement1, ...)".
Keep in mind that this will only work for the new content wizard. When editing an element you can still select any ce from the "Fluid Content type" dropdown.
I'm still looking for ways to show and hide page templates and disable certain elements. I'll try to update this answer as soon as I find something :)
Cheers ...
I have added one custom attribute in category section in admin.
when I have uploaded image, it's look like
in frontend.
I have use $_category->getBannername(); code for display attribute in magento frontend on category page.
Please help
Thanks in advance.
Use the Below Code :
<?php echo Mage::helper('cms')->getBlockTemplateProcessor()->filter($text);?>
Go to System -> Configuration -> Catalogue -> frontend and check option:
Allow Dynamic Media URLs in Products and Categories set it as "Yes"
Underneath that dropdown you can see comment as below too.
E.g. {{media url="path/to/image.jpg"}} {{skin url="path/to/picture.gif"}}. Dynamic directives parsing impacts catalog performance.
This worked for me
<?php echo Mage::helper('cms')->getBlockTemplateProcessor()->filter($text);?>
app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php
replace (line 178)
$directive = sprintf('{{media url="%s"}}', $mediaPath);
with
$directive = sprintf("{{media url='%s'}}", $mediaPath);
I am trying to use page content images in typo3 pages. I have uploaded 2 images and in DB only the filenames are stored.
OK - I found the images in uploads direcory!
But now how I have to display the image?!
I can hrdcode the upload dir url and add the filename from db, but It's realy ugly and not flexible.
I tryed to use <f:image /> but no chance since it's expecting a resource path?!
OK - I found the resource dir but I can't upload images there from the standart typo3 page in cms.
The <f:image /> is realy usefull for me because I need to display images in different sizes and crop them. This all is implemented in the ViewHelper, but I can not tell the ViewHelper to take my image in upload dir.
Please help me how to use the images on pages. The menu for uploading images on page contrent is realy usefull in backend, but I can not display the result in frontend.
In case, the upload directory is set in the TCA columns config (uploadfolder), you can write your own viewHelper and get the upload directory e.g.
/**
* #param Tx_(extkey)_Domain_Model_(entity class) $entity
* #return string rendered image tags
*/
public function render($entity) {
$html = '';
$GLOBALS['TSFE']->includeTCA();
$uploadfolder = $GLOBALS['TCA']['tx_(extkey)_domain_model_(entity class)']['columns']['(column_name)']['config']['uploadfolder'];
$images = explode(',', $entity->getImages());
foreach ($images as $image) {
$html .= $this->getImageTag($uploadfolder, $image, $width);
}
return $html;
}
Have a look at the Tx_Fluid_ViewHelpers_ImageViewHelper class (especially the render method) for code to format your image tags.
try using something like this: <f:image src="uploads/tx_extensionname/{object.image}" alt="foo" title="bar" maxHeight="50" />
See the Fluid Wiki Page