How to display all oembed fields on custom page with ACF - post

I should create a page where you can view all videos (oembed field) of a specific custom post type.
Example:
Custom Post Type = Project
Inside Project there are 4 articles and inside each of them 4 videos are uploaded.
So my question is: how can I structure my feature so that it allows me to extract the videos of all the articles and show them in a single page?

Try this code, but change key of your custom video field
$args = [
'post_type' => 'project', // your custom post type
'post_status' => 'publish',
];
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) { $loop->the_post();
$video = get_field('video', get_the_ID()); // check custom field key
print $video;
}
wp_reset_postdata();

Related

Docusign API and printing documents

I am able to create an e-signature with a pdf on the docusign api that I have setup within the Docusign sandbox. However, one of the requirements for my project is to pre-populate the pdf on docusign and then render it into a browser for printing.
Whenever I create the document within the envelope for e-signature, all of the passed-in fields are in the document. However, if I only create the document, then try to view it, all of the fields I am passing in are blank.
How can I have these passed in fields to stay persistent within the envelope document and then show that document within a browser?
Without seeing your code it's hard to say what you're doing wrong.
I can tell you how it should be done. Not sure what lang you're using. in C# you can do this:
// Add the tabs model (including the SignHere tab) to the signer.
// The Tabs object wants arrays of the different field/tab types
// Tabs are set per recipient/signer
Tabs signer1Tabs = new Tabs
{
SignHereTabs = new List<SignHere> { signHere },
TextTabs = new List<Text> { textLegal, textFamiliar, textSalary }
};
signer1.Tabs = signer1Tabs;
Recipients recipients = new Recipients
{
Signers = new List<Signer> { signer1 }
};
(you can find the full code example and all the other languages in our code example on the Developer Center)

Displaying page Name in the URL instead of page ID in yii?

How to display Page Name in the url instead of Page ID
For example, It Should be
localhost/mysite/index.php/page/about
Instead of
localhost/mysite/index.php/page/1
I have tired from edit actionview()
public function actionView($id)
{
$this->render('view',array(
'model'=>$this->loadModel($id),
));
}
You can create links to ANY url that you like. The issue is how you deal with the data that is passed.
So in your view, create a link.
About Us
This will call the controller action actionView(). You can then handle the page in there.
public function actionView($page)
{
// Load the model with the required page tag.
$pageDetails = Article::model()->findByAttributes(
array('page_name' => $page)
);
// Display the page
$this->render('view',array(
'model'=>$pageDetails
));
}
Updated Answer
Hope you are making your website SEO friendly with pretty URL. If your pages are static web pages such as about, faq, privacy..., you can implement the above answer provided by crafter. In this case page names should unique.
Another way (but not exactly what you want) is url rewriting with native yii feature urlManager. In this case page id will appear in URL like bellow.
localhost/mysite/index.php/page/1/about
localhost/mysite/index.php/page/2/britain-to-support-italys-intelligence-effort-on-migrants
If you observe, most of the News website following the same url structure.
Ex: http://www.telegraph.co.uk/finance/economics/11682277/Greeks-admit-they-will-default-at-the-end-of-the-month-as-central-bank-turns-on-government.html
To do this this in application, you have to write urlManager rules.
'urlManager' => array(
'urlFormat'=>'path',
'showScriptName'=>true,
'rules' => array(
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
//We are adding pretty url for article
'page/<id:\d+>/<title:[a-zA-Z0-9\-_]>' => 'page/view',
),
I am assuming bellow is you Article database table
id title description keywords status
-------------------------------------------------------
1 about some big text some keys active
Now i am making the URl dynamically
<?php
//In Controller
//Fetch articles and send them to view
$articles=Articles::model()->findAll();
?>
<?php
//In View
//Iterate articles
foreach($articles as $article)
{
$id=$article->id;
$title=$article->title;
//Make structured Url.
// Replaces all spaces with hyphens and change text to lowercase .
$titleInUrl= strtolower(str_replace(' ', '-', $title));
// Removes special chars.
$titleInUrl=preg_replace('/[^A-Za-z0-9\-]/', '', $titleInUrl);
?>
$title
<?php
}
?>
You can also change URL pattern as you want. Ex i need url like
localhost/mysite/index.php/page/about-1
For this i have write/change rule in urlManager as
'page/<title:[a-zA-Z0-9\-_]>-<id:\d+>' => 'page/view',
Hope it will help you for your problem.

Pass parameters to rails emails template using Mandrill

I am using Mandrill to send some batch emails.
I have the following code:
m = Mandrill::API.new ENV['MANDRILL_APIKEY']
message = {
:subject=> #template.subject,
:from_name=> #template.branch.name,
:from_email=>"myemail#example.com",
:to=>mails,
vars: {
'MESSAGE' => #template.message,
},
:html=>render_to_string('dashboard_mailer/send_campaign', :layout => false),
:preserve_recipients => false,
}
sending = m.messages.send message
I know I can print the MESSAGE variable by adding *|MESSAGE|* inside my dashboard_mailer/send_campaign.html.erb file. But I would also like to display some dynamic content. For example display #items.name, where items have different size.
Its actually more complicated than just displaying a set of names (I could create a string in the controller and display it with a variable). What I need to display involves some html tags, which is why it could be nice to be able to loop through the variable inside the send_campaign.html.erb file
Is it possible to pass a variable to the rails template?
Thanks

Using the Symfony admin generator to let a user manage a subset of record

My first post here, hopefully It will be right! =)
I am creating a site to manage web application development using symfony 1.4 and doctrine.
My records consist for this problem of Project and ProjectFeatures
Now what I want to do is use the admin generator to let users manage the features for one project thru a link constraining all the returned features by project_id, that would look like: http://mysite/member/project/:project_id/features
in my routing.yml configuration, I have:
member_project_feature:
class: sfDoctrineRouteCollection
options:
model: ProjectFeature
module: memberProjectFeature
prefix_path: /member/project/:project_id/features
with_show: true
column: id
with_wildcard_routes: true
project_id is an existing column in the model ProjectFeature,
I will use a custom query to retrieve features only by that project_id.
Now I can generate a url to link to that admin generator module without error using:
url_for('member_project_feature', array('project_id' => $project['id']))
And the routing system does recognise the url:
May 04 14:30:59 symfony [info] {sfPatternRouting} Match route "member_project_feature" (/member/project/:project_id/features.:sf_format) for /member/project/1/features with parameters array ( 'module' => 'memberProjectFeature', 'action' => 'index', 'sf_format' => 'html', 'project_id' => '1',)
But the admin generator can't generate it's links inside it's templates with that prefix_path and returns error InvalidArgumentException with message The "/member/project/:project_id/features/:action/action.:sf_format" route has some missing mandatory parameters (:project_id).
Any idea?
Well I found my answer at this url: http://www.blogs.uni-osnabrueck.de/rotapken/?s=symfony
But I will give it here and shorten it because, stackoverflow is awesome and it should be there for a long time =)
1st - The routing configuration I used in my question is valid.
2nd - You need to add a method in the action file generated by the admin
public function execute($sfRequest)
{
// taken from http://www.blogs.uni-osnabrueck.de/rotapken/?s=symfony
$this->forward404Unless(
$project_id = $sfRequest->getUrlParameter('project_id'));
$this->forward404Unless(
$this->project = Doctrine::getTable('ttcWebProject')->find($project_id));
$this->getContext()->getRouting()
->setDefaultParameter('project_id', $project_id);
if ($id = $sfRequest->getUrlParameter('id'))
{
$this->getContext()->getRouting()->setDefaultParameter('id', $id);
}
$result = parent::execute($sfRequest);
return $result;
}
At this point the url gets generated correctly but here is the last step to get to the end result you most probably want to achieve:
3rd - To get the list by project_id I can either provide a table method in the generator.yml, a default value to the getFilterDefaults or this method in the action file:
protected function buildQuery ()
{
$q = parent::buildQuery();
$rootAlias = $q->getRootAlias();
$q->andWhere("{$rootAlias}.project_id = ?",
$this->getRequest()->getUrlParameter('project_id'));
return $q;
}
I'm not 100% certain about what you're trying to do here, but it sounds like you need the ProjectFeature::toParams method return the project_id.

Placeholders in symfony's url_for() helper function

I'm working on an AJAXy autocomplete widget. I'm trying to create a symfony URL with a placeholder, which I can then pass to my Javascript, so that the JS can inject the ID of records it has retrieved via AJAX. For example:
$this->widgetSchema['sons_list'] = new ynWidgetAjaxAutocomplete(
array(
'item_url' => url_for( 'person/edit?id=%' ),
// OR
'item_url' => url_for( 'person/%/edit' ),
)
);
But neither of these works - I am looking for /person/%25/edit, but the first yields /person/edit/action?id=%25 and the second yields /person/%25/action. It does work if I pass a placeholder of digits, but this seems like a narsty hack to me:
$this->widgetSchema['sons_list'] = new ynWidgetAjaxAutocomplete(
array(
'item_url' => url_for( 'person/edit?id=999999999999' ),
)
);
Anyone know a cleaner way? Thanks!
If you want to pass only one parameter, you can probably use url_for('person/edit?id=') and then just append dynamic parameter with js.
update
Another way - how about replacing %25 with js?
The main problem was that the auto-generated action was using $this->getRoute()->getObject(), but symfony wasn't able to resolve the URL to sfDoctrineRoute and was stuck with sfRoute, which doesn't have a getObject() method. I have now adjusted my action to retrieve the record based on the id parameter, and started using url_for( 'person/edit' ), appending ?id=123 in the JS, similar to Darmen. I am satisfied with this.
Good question!
Here is my solution (pass to url number and replace it it JS)
function preview_document(NODE, TREE_OBJ) {
var url_to = '<?php echo url_for(sprintf('#document_preview?id=%s', '-999999'));?>';
$.get(url_to.replace('-999999', $(NODE).attr('id').replace('phtml_', '')), function (data) {
$('#document-viewer').html(data);
});
}

Resources