how to make news and articles using the same silverstripe news module? - php

I need to incorporate News and Announcements in my silverstripe website, both news and announcements have the exact same structure and they both use https://github.com/nyeholt/silverstripe-news. in the html template I have two sections one for the news and another for the announcements.
what is the proper way to implement this:
should I just copy and past the /news module folder and use one for the news and the other for announcements.
or add another db field as flag to specify if this is a news article or an announcement article, but then in the cms the user would have to check this every time.
or is there anything else, I don't know

Duplicating the folder would not have the result you expect unless youd rename all the classes in side of the new one.
Basically the folder is just a place for the classes to be, not something that you access when you actually request an news article, you use SilverStripes routes for that.
Static assets would be something that are be loaded from a module folder.
The best way to add a new behaviour to an extension is to use a DataExtension.
See https://docs.silverstripe.org/en/3.4/developer_guides/extending/extensions/
Other way would be if the module uses sitetree for placing the "news holder". Then you have the option also to just create two holders with different names and then if you want to show a list of a paricular parent just filter with the parentId that relates to the correct holder.
Third option would be to just would to add a new class under mysite that extends the modules classes and override only SOME of the methods to suite your needs.

Related

What is the best way to create page in Drupal 8 so that I can then add these posts with images?

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

Yii - Dynamically Loading a Controller

I have had a good play around with the Yii Framework and now I want to take it a bit deeper and what I want to do is set up an application where several different URLs would point to the same controller.
Normally domain.com/content will point to class ContentController which is standard in MVC.
What I want to do is set up three controllers (maybe more but this will do to start), i.e. ArticlesController, DisplayController and SplashController.
I would then set up what is essentially a CMS for a client, and they would be able to create as many pages as they want and point them to the above three controllers, which I have already set up to handle the data.
So for instance my client could set up the following pages: news, notices, technical and have them all pointed to the ArticlesController, and also set up pages: management, specials, support and have them all pointed to the DisplayController.
I know that all those controllers could be creating using the Gii module, but in this case its not an option as I don't think that's suitable for non technical people.
I just want my client to be able to log into the CMS, decide he wants to create a new page called "randompage", point it to the ArticlesController using a drop down menu, then write a bunch of articles for it and now have those articles accessible at domain.com/randompage/article-1 domain.com/randompage/article-2
With the standard set up that would point to site/error because there is no controller RandompageController
What I've done so far is create a constructor in Controller class where I can overwrite the controller id
class Controller extends CController {
function __construct($id) {
// Code here which successfully pulls from the database
// which controller the current page should point to.
parent::__construct($newControllerID)
}
}
If I check in the CController class, $this->_id = either articles, display or splash but the application itself stills loads site/error
I'm guessing I must have to set/override the Controller elsewhere. I have tried
Yii::app()->setController($newControllerID)
but that doesn't have any effect
Perhaps Yii is set up and must require a specific controller for each URL but that would mean developing rather rigid solutions for clients, and requiring them to call in the developer every time they want to add a new controller.
Hope I have explained what I'm trying to do well.
create a page object (id, title, slug, description, image)
create an article object (id, pageId, title, slug, content)
configure your urlManager:
'<pageSlug>/<articleSlug>' => 'article/view'
in your ArticleController->ViewAction evaluate
Yii::app()->request->getParam('pageSlug')
Yii::app()->request->getParam('articleSlug')
to find the right article for that page

Add new entities in OpenCart

I was wondering if I can add new entities (classes/tables) in OpenCart to store information that is not included in the default functionality. To be more precise, I would like to add subscription (3/6/12 months) related information, as described here: OpenCart subscription model (x months)
If yes, can I just add admin pages for the new class? Would something like: How to create a custom admin page in opencart? work?
You would need to create a
Template file (.tpl)
Controller file (.php)
Model file (.php)
Language file (.php)
All files are named the same with different extensions and located in their respective folders
You will also need to add more columns in the database named with the additional settings you ant to store.
In addition to your page specific setup you will also need to add a link to your page in the header file, in the menu.
You will use the model file to insert, update and delete data within the database. The controller controls what functions within the model are used.
Once created, In admin/ user group permissions you need to give access o the new pages
Take a look at the existing files to see how it works. Make a copy of one of the more simpler 4 files, rename, then start to modify them.
If you only want to add more settings to a existing page then you can add them to the existing 4 files and add columns in the database.
Hope that helps get you started, Good luck!

URLs for Joomla Component

I have created a simple basic component in joomla named, careerform so I want to know that what will be its url? Will it be :
index.php/?option=com_careerform
or in sef it will be something like:
index.php/components/careerform
or it will be like this while using .htaccess
/careerform
Is it true or what are joomla default URLs with different settings? Please tell what you know.
thanks for your time.
While what you are asking to do is possible, it would be rather complicated to rename a component. As part of the renaming you would have to update the names of dozens if not hundreds of classes throughout every file of the component. Very likely to run into some bugs because of this.
The far easier prospect is to just avoid these types of urls in your site. Joomla will only fall back to that style of url if a menu item does not exist for the view. Because of that, you can make the url into this:
http://sitename.com/any-component-alias/
To do this, go into the menu manager and create a new menu item. If you don't want this as part of the main menu, you can create a new menu. (I typically have a menu called "Hidden" for menu items that I want aliased but don't actually link to throughout the site from a menu.) When creating the menu item, make sure the type matches the component and view. The alias will then be whatever is entered in the alias box just below the title.
The one issue you may run into with this is that a component may not have a menu type for a particular view. In that case, you you would need to add the necessary metadata.xml file to the view (which again would be much easier than renaming the component!). A good tutorial for that can be found here: http://docs.joomla.org/Adding_view_layout_configuration_parameters.
yes if SEF will be enabled then index.php/component/careerform will be used.
You can create custom URLs by developing a router for your component.
There is very good documentation for it here.

Codeigniter/PyroCMS Extending use of files

I need to produce a few pages that will enable me to display lists of documents (.PDF)
What I want to know is there structure or the compatibility to use the file manager
Example:
I create a folder called animals and inside this folder I have a document called monkey.pdf and tiger.pdf
on the front end of my site I will have a page called articles -> This page will need to list all of the folders created in the file manager
When someone clicks the folder Animals I would like it to list all of the .pdfs within this specific category
Is this possible and could someone show me an example as I am confusing myself.
This is very much appreciated
I have had a thread reply from my query on the PyroCMS fourm.
This is possible it has just not been documented yet and you need to look in the files document for how it works.

Categories