I want to create a new page like you would see in the admin layout editor. I can create a new page from there but its url is always mysite.com/pages/mypage . If i go into engine4_core_pages i can add a page that references my controller and the action i want. So lets say
mymodule_index_mynewpage Somepage
It will display in the LayoutEditor under Editing dropdown as 'Somepage'. When i select that page to either add widgets to it or change the columns all i get in the middle content area is a top Global Header and Global Footer option to hide or show. There is no open area in the middle when i can place widgets. Screen cap of what im talking about
http://i.imgur.com/rDSy26n.png?1
How can i give the page the ability to change layout and add widgets to it? I cant seem to find it.
Edit: adding to answer below
After following the below directions the ability to change the layout is limited. To be able to use all of the "column layouts" you must also place into engine4_core_content.
(auto number), yourpage_id, type=container, name=middle, (parent containers incremented id), order(6 i guess), ["[]"]=params, null=attribs
1234 50 container middle 1000 6 ["[]"] null
At first, you have to create new row in engine4_core_content with type 'container' and name 'main' (of course page_id there is your page_id). Main container contains 'left', 'right' and 'middle' containers.
Then, in the end of action that refers to your page (mymodule_index_mynewpage), you can use something like this to display content which configured using layout editor for your specific action:
$this->_helper->content
->setContentName(48) // page_id
->setNoRender()
->setEnabled();
return;
There are two tables in socialengine which store information about pages and widgets that are used by layout editor:
engine4_core_pages
engine4_core_content
Both are related by the field "page_id".
You have to take in mind this structure:
page (defined in engine4_core_pages)
|
----- container (defined in engine4_core_content, field: type)
|
----- widgets (defined in engine4_core_content, field: type)
Check info in both tables and in your project check the file install.php (inside of //settings
Related
I have a Home page on the Drupal website (such as is created after installation), but I still need to create this page:
What is the best way to create a page so that I can then add these posts with images?
I am just starting to learn Drupal and have heard so far about such ways of creating pages:
1) in admin toolbar: Content / Add Content / Article
2) in admin toolbar: Content / Add Content / Basic page
3) in admin toolbar: Structure / Views / Add Views
Which one should I use? Or maybe there is some other option that I don’t know about?
P.S. At the moment I am more interested how to create empty page on which I can then add posts later, and adding posts it is another question.
Welcome to Drupal.
Drupal ships with the default theme which won't look nice but it does its job in the right way. Now if you want to create a better UI/UX obviously you should create a new theme. But before that make sure to read and understand the concepts behind Drupal. Drupal docs are your first friend.
Drupal Documentation
Drupal considers everything as nodes and that's how Drupal got its power. As you mentioned, Articles, Basic Page etc are called content types and they can be used to create a particular type of content.
Now for your purpose create a new content type and add the fields you need. From the image above I can say your content type needs Title, Image, Category and Date. After creating content type you can create as many contents as you want under the content type you just created. Consider each card in your image as content.
Now you can use a Drupal Core Module Views, to perform DataBase Operations without writing single code. Yes, you can select fields, sort, order etc with Views UI and display it in a page or a part of a page (Block).
I would say just try this out in the default Drupal theme and when you understand how this works, you can start creating your own theme for your project.
Theming Drupal
There is a lot of resources available. But you have to make sure what you are asking is whether you actually need. It will take some time, but it worth.
To build layouts for homepages on Drupal 8 you best friend is https://www.drupal.org/docs/8/core/modules/layout-builder
To build the content blocks inside your home page, you should start creating nodes on a node content type to hold your information. For instance: news content type, with a title, a body, a date, and an image.
For every node type, ex. news, work on the preview display, full display, and any other display which makes sense. These displays can be used later in the Layout Builder directly or in Views, referenced below.
If you wish your list to be dynamic, such as the last 10 entries are shown first, then use a view to hold the content sorted and filtered as you need.
In a nutshell.
Create a content type for your article/news.
Modify the displays of the content types to have at least a summary and full view.
Create the content itself to have something to see.
Create the view (block) to filter and sort your content.
Create a page layout (this makes sense for landing pages) which places your new view and any other content you need in any disposition.
This is roughly what I would do. The steps described above contain many intermediate steps. If in doubt, check the docs.
I hope that helps!
First, decide what will you display on that page. Is it content in some existing content type (article maybe) or you want to crate new one for this purpose.
If you need new one then create it (Structure -> Content types -> Add content type).
Then check what fields will you need. I.e. image, some description text. Add missing ones.
Create few nodes (pages) in that type so you could work with them.
Then for displaying you should crate a view (Structure -> Views -> Add view). It can be a page view (you are displaying only that content on page) or block view (this is just a block among some others). If you create a page you could visit it and if you create a block you have to add it to some region to appear on page (Structure -> Block Layout).
Inside your theme you should create templates for this page/block. Turn on twig debug mode so it will show you hints - what templates are used and how can you name yours to override default ones.
Adjust CSS to make it look like you want it to look.
Find some tutorial(s) for the details
Previous answers have given the flow of the work you should go through, I would like to add some resource that might help you achieve this.
Creating content type and fields: https://www.drupal.org/docs/administering-a-drupal-site/managing-content-0/working-with-content-types-and-fields
https://www.drupal.org/docs/user_guide/en/structure-content-type.html
View and View modes: https://www.drupal.org/docs/user_guide/en/views-concept.html
https://www.drupal.org/docs/8/api/entity-api/display-modes-view-modes-and-form-modes
Handling block of the view: https://www.drupal.org/docs/8/core/modules/block/overview
Feel free to ask if any further explanation is needed.
Thank you
In Drupal, I would like to add a custom field to Basic page content type, but only to one Basic page with a particular node ID.
I know I can add custom fields to the whole content type but this is not what I want.
For example, is it possible to add a file upload field only to Basic page with node ID of 5?
Using Views you can create the list of nodes that you would like to display on the page. The new version of views makes it super easy to do that. From there you have a couple options, depending your level of skill with theming and how much control you need to have over where the list of nodes displays:
A Block - Create a block display for your view. Place the block in the same region as the main content block.
node--NODEID.tpl.php - You could add a template suggestion to your theme to override the specific node that you want to add the list to. To do that you would need to:
Create a node--NODEID.tpl.php file, replacing the NODEID with the nid of the node you want your list of nodes to show up on.
Embed your view in the node template using the following code:
nid); ?>
Where MY_VIEW is the machine name of the view you created and MY_DISPLAY is either "default" or the machine name of a specific display in your view.
Here is an example: http://api.drupal.org/api/views/views.module/function/views_embed_view/7#comment-32858
I am busy trying to customize Joomla's Menu Parameters so that in the administrator area when you create a new menu item, You have an additional option of "1 Column" or "2 Column", And this has to be both accessible by the index file of the template and also Joomla! Update Friendly..
And this is basically just to give the user the freedom of selecting the layout style of a particular page.
What Would be the Best way to go about this?
Any Help Greatly Appreciated.
UPDATE
what i am trying to achieve is similar to when you select a category for a menu item in Joomla!, I want to append it to the url exactly like a category, so you select 1 of 2 columns when creating a menu item and then in the url it should say: &col=1 or &col=2.
Joomla already has a built in parameter for selecting the layout used for a menu item which is the concept of an alternative menu layout. You add the layout to your template html folder with the appropriate xml file. Then that layout will show up in the list of menu options when you select a menu type.
I have two simple solutions without core haking and that are update friendly.
SOLUTION 1 :
Make 2 different templates with the 2 different layouts call them 1 column and 2 columns. When you make your menu link you can choose between them (Template style dropdown).
SOLUTION 2 :
(the one I would recomend)
In your css file make your 2 different layouts based on 2 different css Classes. For example class="1_column" and class="2_columns".
When you make your menu link , under "page display options" you can choose a class for the page it links to. And there you are you can choose between your two layouts.
Hope this helps!
Can someone pls guide me with this?
I have five images associated with a node which I have kept hidden. I want to show them in a block.
How do I show the images in the block belonging to the CURRENTLY DISPLAYED NODE?
So that as the node changes, it will automatically load the images of that node on the block?
I figured this has got to do with adding filters.
But I cant seem to get any
'current node' filter as such when I was seeing those lists.
I also read that I can pass an argument of the current node to the block. But In drupal 7, there is no such field called 'arguments' while editing the block....
Thanks
You can do that using views.
1- Create a new views block.
2- Under Fields section, choose your images field.
3- Under Contextual filters click Add then choose Content: Nid
4- Under When the filter value is NOT available choose Provide default value then Content ID from URL, then click Apply.
5- Save your view and go to the blocks manager page admin/structure/block and click configure beside your new views block.
6- Navigate to the bottom of the page to Content types, then check the content types you wanna have this block to be shown.
Hope this helps... Muhammad.
I've created a new content type called Homepage, which has a number of fields. The fields are node references to the Single Image Promo content type. Single Promo Box has fields for title, text and image. The idea is that I can create multiple copies of a Single Promo Box, each with different field values. I then want to place a few of them on the homepage.
So I can place a specific Single Image Promo on the homepage fine now. But what template file do I need to create to style the way Single Image Promo is shown when it's a node reference on the homepage?
Thanks,
Maria
It sounds like you are over complicating things.
If you want to create some different boxes on your homepage, using node reference is not the right way to go about this. There are some few different ways to do what you want, the easiest i probably to create a block view of the node you want to display. When you turn a node into a block, you get the ability to place it in any of your theme's defined regions.
You could also just create a view and from there get the different Single Image Promo you want without using node reference at all. Views has a lot of different filters, which will enable to you create a view that always displays the right nodes. This solution wont work well, if you want to place the nodes in different regions though.
To answer your question, when nodes are being displayed, they will by default be rendered with the node.tpl.php template file. To make specific templates for each of your node types, you can create a new template named node-nodetype.tpl.php, where nodetype is what you called the node type when you created it.
node-nodetype.tpl.php can work to a certain degree, but in that file you are styling the entire page, with the content type's fields delivered wholesale to the tpl via a single $content variable. Maybe it is enough for you, but if you need finer grained control:
You can edit and style the individual content type's fields with the Content Template (contemplate) module. It provides access to all of a content type's fields within the $content variable (which is delivered wholesale to the node-nodetype.tpl.php. The contemplate is php, so you can add logic and conditional formatting for the node-reference fields (usually clearly labeled in the contemplate).
And don't overlook the simple solution of the content type's 'display fields' tab (next to manage fields tab), where you can control some field outputs right out of the gate.