Taking only the title of the content, strip tags

Talk about all extensions including themes.

Taking only the title of the content, strip tags

Postby elegos » Wed Jan 28, 2015 9:50 am

Hello!

I browsed several little CMS and now I'm facing razorCMS. So far so good, problem is there is little documentation.

I'm trying to convert a static template into a razorCMS one. First thing I came across is to get a content's title. What I want to do is to assign a H some classes automatically, so best thing I thought was to set it via the content's title.

Also, sometimes, I'd like to strip away paragraphs or other tags without having to do it in the code editor (you know, I could without any problem, but not a copywriter). As $this->content('region', num) prints the content, I don't know how I can pass it as variable and eventually strip / alter the content.

Thanks

Edit: sorted out how to do this.

razor_site.php, line ~86+ (add $asVar = false to the arguments)
Code: Select all
   }

   public function content($loc, $col, $asVar = false)
   {
      // create extension dependancy list

razor_site.php, line ~166+ (return the content if $asVar is true)
Code: Select all
         if ($c_data["location"] == $loc && $c_data["column"] == $col)
         {
            if (!empty($c_data["content_id"]))
            {
               // load content   
               if (!$asVar) echo '<div ng-if="!changed" content-id="'.$c_data["content_id"].'">';

               // content
               $content = $this->db->get_first('content', '*', array('id' => $c_data['content_id']));

                    $content["content"] = str_replace("\\n", "", $content["content"]);
                    if ($asVar) return $content;
               echo $content["content"];

               echo '</div>';
            }


Then I can access the content as $this->content('section', column, true), even though the preview feature won't show the data properly (little con of doing this way, but it gives you more control over it).
elegos
 
Posts: 3
Joined: Wed Jan 28, 2015 9:42 am

Re: Taking only the title of the content, strip tags

Postby smiffy6969 » Wed Jan 28, 2015 7:09 pm

Hiya,

Welcome....

few things first..... sorry about the loack of documentation, I was beginning to get this kind of thing down on the website, but recent heavy updates stopped this as we moved to sqlite, it will get there but relies on me and only me to do this :(

1) To get a page details you can do the following in the template

Code: Select all
<?php echo $this->site["name"] ?>
<?php echo $this->page["title"] ?>
<?php echo $this->page["description"] ?>
<?php echo $this->page["keywords"] ?>


This data is pulled from the data you set for each page in the admin overlay.

We do not actively push titles from content though, as content does not have to have a title, plus it can be used as many times as you like on a page as you assign content to a page. Content is completely agnostic in this regard, we create lots of snippits of html content and then place them on a page where you want them..... If you want to add a title to the content, just put the h tags in the content code, at least this way you get to decide when you want content to show a title and when not too as apposed to a template showing content titles all the time regardless.

I am assuming when you say content title, you mean page title.... basically think of razor pages as a frame, and the content as the blocks you place in the frame.

2) regarding the altering content before displaying it, you do realise auto updates will strip out these changes in core files!

Why don't you tell me what you are actually trying to achieve, there may be another way. Maybe I can put something in place in a next update but I need to understand what you are actually trying to achieve.

In time I will get more info up there, please be patient.

ta

Paul
smiffy6969
 
Posts: 1866
Joined: Sat May 24, 2008 8:18 am
Location: Loughborough, UK

Re: Taking only the title of the content, strip tags

Postby elegos » Wed Jan 28, 2015 8:47 pm

Hello smiffy6969,

thanks for your kind reply :)

What I'm trying to achieve (maybe not in the right way?) is to get a plain HTML theme and transform it in a template with several views (i.e. main, portfolio item, etc).

For example the main page: it is actually composed by several section tags with one or more title / paragraph elements, for example:

Code: Select all
<section class="whatever" style="background-image: path/to/image/I/want/to/set/via/plugin(?).png>
    <div class="my container classes">
        <h3 class="my h3 special classes">Project title, with an optional anchor to the relative page</h3>
        <h5 class="my h5 special classes">My project little description</h5>
    </div>
</section>


So, what I need to achieve is:
1. get a list of sections, composed by:
- an image which has to be set as background of the section
- one or more projects, composed by:
-- a title
-- a description

2. write them down via the editor.

If it was purely for me, I could do that manually inserting the various tags, but that's not what a usual copywriter (who knows little of HTML) wants to do (specially to copy all the classes without missing one).
If razorCMS doesn't support templating inside the editor, it's hard to make it work "plain as writing a document in word" as it is supposed to be (am I wrong?). Also, how can I upload and use the image I want to use as background of the section? I think I could easily upload it via FTP and then link it, but how?

Summary:
a. how can I get lists of sections of a page with their relative pages?
b. how can I set an image as CSS of each section?
c. how can I put the text in the right place, as explained, without having to always inserting the right classes in each element?

Not to overload with information, but I installed the photo-gallery extension in order to look how to create a plugin, may you please explain it better, the skeleton of it please?

Thanks :)
elegos
 
Posts: 3
Joined: Wed Jan 28, 2015 9:42 am

Re: Taking only the title of the content, strip tags

Postby smiffy6969 » Wed Jan 28, 2015 9:44 pm

Hiya,

I have read that post a few times and my head hurts ;) can you give me a pictorial example as I am still not totally sure what you are trying to do.

Regarding the editor, it is a simple markup editor. You write like you would in a word processor and it formats the HTML for you. Sure it follows the same rules as a word processor, looks like one and allows you to do simple things like justification, colour, inserting etc. You should not be really styling layout in it, if you find yourself doing layout stuff in the editor then you have missed the concept of theming.... Themes do layout, content is then slotted into theme areas.

This aside it is more than possible to add bootstrap HTML markup into the editor, it will even work with JavaScript off the bat.

Try going to bootstrap website, look at the markup, don't worry about the JavaScript, it is already loaded to make interactive elements work so you should be able to do things like accordion, modals that kind of thing by just pasting the code into the editor.

You may find something on the bootstrap website that will help to give you some form of layout/organising of content.

If not, do me a mockup of what your looking for and I will tell you how to achieve it.

Ta

Paul
smiffy6969
 
Posts: 1866
Joined: Sat May 24, 2008 8:18 am
Location: Loughborough, UK

Re: Taking only the title of the content, strip tags

Postby smiffy6969 » Wed Jan 28, 2015 9:49 pm

FYI....... Theme guide

http://razorcms.co.uk/documentation

Not sure if you seen this, if not its a good start point.

Paul
smiffy6969
 
Posts: 1866
Joined: Sat May 24, 2008 8:18 am
Location: Loughborough, UK

Re: Taking only the title of the content, strip tags

Postby smiffy6969 » Wed Jan 28, 2015 9:49 pm

FYI....... Theme guide

http://razorcms.co.uk/documentation

Not sure if you seen this, if not its a good start point.

Paul
smiffy6969
 
Posts: 1866
Joined: Sat May 24, 2008 8:18 am
Location: Loughborough, UK

Re: Taking only the title of the content, strip tags

Postby elegos » Wed Jan 28, 2015 10:12 pm

Hello Paul,

this is the template I have to implement: http://multia.in/theme/miagency/demo1/index.html

As you can see, there are sections with background images and (in this case) one project and an anchor to it (which is obviously fake). The user (not developer) should be able to insert the section's image and (at least, if not possible multiple contents) a project name and description per section. There should be no sections limit (i.e. 0-n sections).

Now... I'm a web developer, I know bootstrap and I know I can simply copy/paste HTML code, but for copywriters, this is not an option.

Is it possible to do that?
elegos
 
Posts: 3
Joined: Wed Jan 28, 2015 9:42 am


Return to Extensions

Who is online

Users browsing this forum: No registered users and 1 guest

cron