How to insert content from html code template from different database table - php

I am trying to create a html code template. The problem is there are two html code template saved on different table my problem is merging the two codes when generating.
Here is a simple example:
Database Table 1 - this is where I store the structure of the html section:
<div class="card">
<div class="card-body">
// content will be put here
</div>
</div>
Database Table 2 - this is where I store the content that will be going inside on what's inside the Table 1.
<h5 class="card-title">Special title treatment</h5>
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
Go somewhere
When generated the html code should look like this
<div class="card">
<div class="card-body">
<h5 class="card-title">Special title treatment</h5>
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
Go somewhere
</div>
</div>
The reason I did like this is because the contents inside are flexible meaning can be added, removed, reorganized. What can I do to achieve this?

You can add an anchor on your first table.
<div class="card">
<div class="card-body">
<my-unique-tag>
</div>
</div>
and replace that anchor with your second table data.
$result = str_replace('<my-unique-tag>', $secondData, $firstData);

Related

Is is possible to get WPBakery generated rows as a variable?

I'm creating custom elements in WPBakery (formerly Visual Composer), but encountering issues with its rendered markup.
For example:
I've created a custom element called text. text currently spans 12 columns in the WP admin:
The rendered markup for this looks like:
<div class="row justify-content-center">
<div class="text">
<div class="text-left container">
<h2>This is header</h2>
<p>This is content</p>
</div>
</div>
<div class="col-sm-12">
<div class="vc_column-inner">
<div class="wpb_wrapper"></div>
</div>
</div>
</div>
As you can see, it's creating an empty col-sm-12 div and not even applying the column styles to text.
Ideally what I want to do is get the column WPBakery is generating and place it in a variable.
This way, I can do something along the lines of:
<div class="text <?php echo $column; ?>">
I think this will be handy when a user eventually decides they want two text blocks next to each other:
So each text block will be col-6.
To summarise, I'm trying to figure out why Bakery is outputting an empty div with columns rather than to wrap around my text block? As I'm not sure why this is happening, the only solution I can think of is to get the column data as a variable and then echo is in the text block.

Different Article Views for codeigniter

how would I go about having different views for an article in Code Igniter.
For example I have one Index for all articles and I also have a view. But what If I want to have say 10 pictures for one article and only three for another?
So my view is:
<div id="wrapper">
<div id="main-wrapper" class="col-md-10 pull-right">
<div id="main">
<div class="col-md-9">
<div id="sec#" class="">
<h2><?= $article['title']?></h2>
<img border="0" src="<?= assetUrl() ?>img/article/<?= $article['image']?>">
<h6>Date: <?= $article['date']?></h6>
<h6>Author: <?= $article['author']?></h6>
<br>
<p><?= $article['body']?></p>
</div>
</div>
</div><!--/right-->
</div><!--Main wrapper-->
</div><!--Wrapper-->
All the articles look the same. But what if I want to have pictures within the body of the article? And what if the number of pictures are different for each article.
I'm struggling with this, because all the articles look the same. And depending on the text, it would be nice to render pictures on different parts of the body.
Also, I've been adding HTML tags in the longtext and I save them in the database. Isn't this dangerous? I'm sure there must be a better way of doing this. But if I don't put any tags, the body just displays as one big blob of text.

Bootstrap grid not working when file is included

I already made a homepage including the grid system of bootstrap, but now im using mainly includes to keep everything tidy but the grid system doesnt seem to work at all. even if i copy the example code of bootstrap itself.
this is the first code of my content php file. including obviously the row part. These are stacked ontop of eachother not next to eachother.
PS: the .content-wrapper has no styling yet so its not affecting anything and the .content has only top and bottom padding.
<div class="content-wrapper">
<div class="content">
<h1>The Test Heading</h1>
<p>
text
</p>
</div>
<div class="row">
<div class="col-sm-6 col-md-6">
<div class="thumbnail">
<img src="..." alt="...">
<div class="caption">
<h3>Thumbnail label</h3>
<p>...</p>
<p>Button Button</p>
</div>
</div>
<div class="thumbnail">
<img src="..." alt="...">
<div class="caption">
<h3>Thumbnail label</h3>
<p>...</p>
<p>Button Button</p>
</div>
</div>
</div>
</div>
here is the index.php file i got with the content area
<div class="container">
<!-- Navigation area -->
<?php include_once ("php/navigation.php");?>
<!-- Carousel -->
<?php include_once ("php/carousel.php");?>
<!-- Content area -->
<?php include_once ("php/content.php");?>
</div> <!-- end of container -->
im not sure if it has to do something with including a file and the grid system, but carousel, container etc all working fine so it should find the css file after being included.
Sidequestion: is a method like this useful? working with includes only? or is it rather non-practical?
So what do u want to do with grid system, because you only have one col so it will just go from begining of file to col 6 it will look like it doesnt do anything rly? You can put lets say and then your div with col and it will move it and so on.

How to manage links in an automatic way?

In my project's homepage there must be some images, these must link to other pages. Now, I want to manage these links in an automatic way using PHP. The only idea I came up with is to make a form and insert the images into some buttons and make their background invisible.
<div class="container">
<div class="row">
<div class="col-md-4">
<h3>FRESH ALBUMS</h3>
</div>
</div>
<div id="myline"></div>
<div class="row">
<div class="col-md-3">
<img src="contentimg/abbeyroad.jpg" height="200px" width="200px">
<div class="caption">
<h4>Beatles</h4>
</div>
<p> test</p>
</div>
<div class="col-md-3">TEST2</div>
<div class="col-md-3">TEST3</div>
<div class="col-md-3">TEST4</div>
</div>
</div>
This is the HTML at the moment. I just want to know if there are better ideas, options and if it will stay responsive. Thanks in advance.
I do not understand exactly what you are asking, but I cannot leave comments so I will try to answer what I think you are asking.
For the HTML part, you don't need a form with buttons, you can make hyperlinks out of the images instead, and the PHP can get the images to match the hyperlinks when it sends the page to your users browser. The PHP code would look like:
echo "
<a href='".$newPageLink."'>
<img src='".$imageLocation."' width='100px' height='100px'>
</a>";
Where $newPageLink is a variable in your PHP script that holds the path information for your hyperlink, and $imageLocation is the path information for where the image is stored.
All you need is a foreach or while loop to go through all of the images that you want on the page and also all of the pages that each image should link to. If it is always a manageable and unchanging list, you could store the values in an array in your script. For larger lists, or lists that are dynamic/always changing you might need to use a MySQL database table to store the image and hyperlink information.

How to place a header image above navigation in WordPress

I am using theme Banshee on (http://adriangraphics.com/truturf/) and can't figure out how to put a header image (as seen on http://globalsynturf.com/) above the navigation. I want my logo, along with phone number, etc above the navigation on my WordPress site. I'm assuming I have to change the Header PHP, but unsure how.
In your header.php find:
<div class="row">
Then inside of this find:
<div class="3">
<div id="logo">
Take the contents of this entire div, and cut it.
Then above the <div class="row">, make the following:
<div class="row">
<div class="span12">
<div id="logo">
//rest of the logo code
</div>
</div>
</div>

Categories