How to show list of custom objects in a page in Drupal - drupal-6

I want to create a page in Drupal 6 where I can show list of restaurants.When a user clicks on any restaurant page, I should be redirected to Restaurant details page.
For this :
1.) I created a new content type called "Restaurant" with some fields.
2.) Created 3-4 content items for Restaurant( Restaurant1, Restaurant2, Restaurant3)
3.) Created view called: RestaurantList, Added Fields for it. Then added Page Display and gave the path for it http://website/Restaurants
Now, when I browse to Restaurants page, I only get labels of my fields but no values. How can I get the values but not the labels? Also, I want to go to the RestaurantDetails page. How can that be achieved?
Thanks,
Rashmi

Well if I were to set up a page view this is how I would set it up:
Filters:
Node type - Restaurants
Node published - Yes
Fields
Node title
check the option Link this field to it's node
leave the Label: field empty
check option Hide if empty
And if your view style is a HTML list, for extra you can go to Row style options and check the option: Hide empty fields
Make sure you click Preview to see if you get any values. If you don't then there's something wrong with the view settings, most probably the filters which are to restrictive. Start with something loose, like Node type - Restaurants.

Related

Add list of item in editor view page of orchard cms driver class

I try to create custom content part with following specification.
I need to add list of items in database with same editor template view page of driver.
I want to include one form with required fields with an add button, by using this add button I want to add more number of rows with given field values in database.
I have checked Orchard documentation in this link, they provide sample with single item add in editor template page. In my case I need to add multiple items in editor page.
In display view page of driver, I want to retrieve collection of data from database and rendered in display view page.
Please share some details for this.
Thanks,

Orchard CMS - limiting pages to only a specific layer - how?

Silly really - but I just can't seem to find my way around this just yet....
I installed the Orchard CMS in Azure - worked like a charm, added a few pages, played around, watched the Pluralsight "Orchard Fundamentals" course - seemed to make a lot of sense.
But now I'm stuck - I'm trying to create a public facing site, where some of the pages should be visible to any visitor including anonymous users, and some of course should be visible to only authenticated users.
OK, so I understand those are layers in play - default for everyone, authenticated for authenticated users - great. But how do I limit a given page which is present as Content in my dashboard so that it'll be displayed only on a given layer (e.g. only on the authenticated layer - not the default layer for everyone)
Seems like a simple task - but I just cannot seem to find the way to do it (nor does any of the docs or tutorial videos really help :-( )
Any takers?
Layers are only for widgets. In order to restrict access to a content item such as a page, what you need is content item permissions. That's a separate feature that is not enabled by default.
To enabled the Content Item Permissions module
In the admin panel go to Modules
Start typing permissions into the filter box at the top left hand corner of the tabs.
The Content Item Permissions should be shown in the list, click Enable in the top right hand corner of its box
This will reload the page and you should see a message at the top saying Content Item Permissions was enabled
Enabling this feature with your pages
Orchard CMS uses a concept where you can glue components together however you want them to be composed in order for them to support the features you want. The concept of a page is just a collection of parts like a page title, a url, text, setting a publish date and things like that.
By default simply enabling the module doesn't make any difference. You will need to add the feature to the Page content. To do this you just need to:
In the admin panel go to Content Definition
Find / filter the Page content type and click Edit on the right hand side
Scroll down to Parts and click Add Parts
Search for Content Permissions in the list, tick the checkbox and press Save at the bottom of the page
You will be taken back to the Page content definition screen. At the bottom of the Parts list you will now see a Content Permissions entry. If you want to set up defaults for new pages click the little > arrow to the left of the header and a panel will expand.
If you want to add it to other content types such as blog posts then you can repeat this process and add it to any content type you want to.
Making an individual page password protected
Now that the feature is enabled and attached to your Page content type you can create a new private page by following these steps:
In the admin panel click New > Page in the sidebar
Give the page some basic content
Scroll down close to the end of the page and tick the checkbox labelled Enable Content Item access control
Let's say you want to make it so anon uses cannot see the page. Under the View this item section just tick all of the roles except for Anonymous (the second one in the list)
Publish the page
Open up a new incognito / in-private browser tab (so the site thinks you aren't logged in) and visit the new page you just published.
You will be redirected to an error screen similar to this page:
You will want to enable the Content Item Permissions feature in order to restrict individual content items to certain permissions. With layers you can only make widgets appear in different zones defined in your theme when the layer's rules are met.
To enable the Content Item Permissions feature, go to your admin dashboard and click on "Modules" on the left hand side. On the modules page enter "Content Item Permissions" in the filter text box to help find the feature. Click on the enable button of the feature in the top right corner. The feature will now be enabled.
Now that you have the feature enabled, you need to add the Content Permissions part to one of your content definitions. To do this click on "Content Definition" on the left hand side of the admin dashboard. Find the content type you want to add permissions to (for instance, Page) and click the edit button. Click the Add Parts button. You will see a list of parts you can add to the content type. Check the checkbox next to Content Permissions and click save.
Next, in the admin dashboard go to one of your content items that is of the content type that you just added the content permissions part to. You will see a new checkbox towards the bottom to enable content item access control. Click the checkbox and you will be able to set the different roles for that content item.
Edit: It looks like it took me too long to write my response. rtpHarry's editted answer is very similar but better formatted.

displaying a list on screen with orchard

Using orchard cms 1.6 I have a table in my db 'cars'. I want to display the column 'CarName' from the table, as a list on screen with all the records from the table.
carname1
carname2
carname3
When the user clicks on their link it will bring them to that page.
I know how to do this from the view e.g.
#T("Cars")
but I would like to try and create a content type which shows this list.
Content type seems to be all UI related. Im not sure how to take a table and display a column as a list on screen through the content type...any idea on how to do this?
then I can choose to show the content type as a form and the user can view it from the main menu.
thanks
It looks like you want to create a content type called Car, possibly with a CarPart and a record class CarPartRecord (perhaps refactor your Car class to CarPartRecord to follow Orchard's naming conventions). Make sure CarPartRecord derives from ContentPartRecord.
To render a list of Cars, you could use a Projection that renders a list of cars. A Projection renders content based on a Query, which you configure using the dashboard.
Alternatively, you could create a controller that leverages IContentManager to query all Car content items, and returns a view to render them in a table.
For each Car content item, use Html.ItemDisplayLink to render a link to its details page.

How can I use base_path() inside a view in Drupal?

I have the following fields inside a view:
User ID
Teaser
I selected "exclude from display" for the User ID field.
In the Teaser field, I selected the "rewrite the output of this field" option. This way, I can use html to completely control the structure of the view's output. Moreover, I can call the User ID field by using it's token, [uid].
For example, I can do the following in the teaser's rewrite:
Visit Profile
The problem with the above code is that the path is relative. It will only work on the front page of the site.
For example, if this link is clicked in
www.example.com/node/1
then it will visit a non-existent URL of:
node/1/user/[uid]
I have tried the following: http://chopapp.com/#o7osql65
But views fields does not allow PHP codes.
I might be approaching this entirely wrong. Does anyone have any suggestions? Thanks.
You'll want to rewrite the output of the UID field, and have it be rendered as a link. Even if you exclude it from display initially, it will still be available as a link via its token to other fields. One of the options when selecting to 'output this field as a link' is to make the link absolute.

Drupal: hiding the view to display the results?

i m newbie to drupal
i have a view which displays the list of cars , i have 2 filters which are exposed make users to search for the car model and price.
it works fine, now i want this view to be home page, by default views gives list of all the nodes.
i dont want that, the results should display after users presses apply button
can any one help me to do that...
Go to /admin/settings/site-information and enter the path to your view in the "Default front page" field.
PS. your site cannot be Drupal 5 and Drupal 6 at the same time. Please tag your questions correctly.

Resources